InvalidCharacterError: String contains an invalid character when registering custom element

RESOLVED FIXED in mozilla30

Status

()

Core
DOM
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: sole, Assigned: wchen)

Tracking

unspecified
mozilla30
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

I can't register custom elements because I get this totally unexpected error when calling document.register:

document.registerElement('colourful-button', { // <-- BOOM!
  extends: 'button',
  prototype: buttonPrototype
});


See the linked example for a live demonstration!
http://people.mozilla.org/~spenades/test_cases/document.register/

I'm using Firefox Nightly 20140126.
For comparison this works in Chrome Canary which has web components enabled now.
The code has:

5260   if (!StringBeginsWith(lcName, NS_LITERAL_STRING("x-"))) {
5261     rv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
5262     return nullptr;
5263   }

Pretty sure the spec draft required this behavior back when we implemented this....  It looks like it's since been changed to the behavior described at http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type which allows all NCNames that don't match a specific blacklist.  It's not clear to me why the change, since the new behavior effectively reserves all names containing "-" for custom element use, which seems a bit odd.
(Reporter)

Comment 2

4 years ago
Oh, that would explain the "crash".

I was reading the explainer yesterday, it definitely only asks you to have a hyphen now. The "x-" requirement has been dropped AFAIK.
(Assignee)

Comment 3

4 years ago
The implementation currently in the tree is a very old version of the spec. There are patches for an updated implementation in review right now (Bug 856140).
Depends on: 856140
(Reporter)

Comment 4

4 years ago
This works correctly in Nightly now. Many thanks to all of you who worked on this bug!
Closing bug :-)
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Assignee: nobody → wchen
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.