Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 73673b5

Browse files
committed
Fix issue with non identifier names
1 parent 2a41b2f commit 73673b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/wrappers.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,24 @@ var ShadowDOMPolyfill = {};
103103
return /^on[a-z]+$/.test(name);
104104
}
105105

106+
function isIdentifierName(name) {
107+
return /^\w[a-zA-Z_0-9]*$/.test(name);
108+
}
109+
106110
function getGetter(name) {
107-
return hasEval ?
111+
return hasEval && isIdentifierName(name) ?
108112
new Function('return this.impl.' + name) :
109113
function() { return this.impl[name]; };
110114
}
111115

112116
function getSetter(name) {
113-
return hasEval ?
117+
return hasEval && isIdentifierName(name) ?
114118
new Function('v', 'this.impl.' + name + ' = v') :
115119
function(v) { this.impl[name] = v; };
116120
}
117121

118122
function getMethod(name) {
119-
return hasEval ?
123+
return hasEval && isIdentifierName(name) ?
120124
new Function('return this.impl.' + name +
121125
'.apply(this.impl, arguments)') :
122126
function() { return this.impl[name].apply(this.impl, arguments); };

0 commit comments

Comments
 (0)