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

Commit

Permalink
Fix issue with non identifier names
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Oct 23, 2013
1 parent 2a41b2f commit 73673b5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); };
Expand Down

0 comments on commit 73673b5

Please sign in to comment.