From 73673b56fdaa38acad63e54d5e793be0eedf004a Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 23 Oct 2013 14:46:46 -0400 Subject: [PATCH] Fix issue with non identifier names --- src/wrappers.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wrappers.js b/src/wrappers.js index cbb703b..28f7536 100644 --- a/src/wrappers.js +++ b/src/wrappers.js @@ -103,20 +103,24 @@ var ShadowDOMPolyfill = {}; return /^on[a-z]+$/.test(name); } + function isIdentifierName(name) { + return /^\w[a-zA-Z_0-9]*$/.test(name); + } + function getGetter(name) { - return hasEval ? + return hasEval && isIdentifierName(name) ? new Function('return this.impl.' + name) : function() { return this.impl[name]; }; } function getSetter(name) { - return hasEval ? + return hasEval && isIdentifierName(name) ? new Function('v', 'this.impl.' + name + ' = v') : function(v) { this.impl[name] = v; }; } function getMethod(name) { - return hasEval ? + return hasEval && isIdentifierName(name) ? new Function('return this.impl.' + name + '.apply(this.impl, arguments)') : function() { return this.impl[name].apply(this.impl, arguments); };