Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidCharacterError on document.register if $ exists in constructor function name #362

Closed
gkdn opened this issue Dec 7, 2013 · 2 comments

Comments

@gkdn
Copy link

gkdn commented Dec 7, 2013

If there is a $ character in constructor function name and constructor function is passed as the second argument to document.register, following exception is thrown:

InvalidCharacterError: The string contains invalid characters.

Following code snippet illustrates the problem:

function A$A(){}
A$A.prototype = Object.create(HTMLButtonElement.prototype);
new document.register("a-a", A$A)(); // Fails
new document.register("a-a", { prototype: A$A.prototype } )(); // Works

(Tested in Chrome 32.0.1700.41 beta - experimental Web Platform features is disabled)

@dfreedm
Copy link
Member

dfreedm commented Dec 16, 2013

The problem here is that the we're using the second argument to hold metadata. In particular, we're mapping element name to name: https://github.com/Polymer/CustomElements/blob/a2039d/src/CustomElements.js#L115, and function.name is a readonly property.

When resolving the final tag name, definition.tag is populated by defintion.name in the fallback case, and this means that new A$A will translate to document.createElement('A$A') instead of document.createElement('a-a')

@dfreedm
Copy link
Member

dfreedm commented Dec 16, 2013

Fixed by googlearchive/CustomElements@8ee223eb

@dfreedm dfreedm closed this as completed Dec 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants