Closed Bug 503210 Opened 16 years ago Closed 15 years ago

Relax createElement tag name requirements to match HTML5 parser

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jruderman, Unassigned)

Details

Entering javascript:alert(document.createElement("a<b")) gives NS_ERROR_DOM_INVALID_CHARACTER_ERR: String contains an invalid character but the HTML5 parser is happy to create such an element. I think createElement should be changed to match.
Summary: Relax createElement tag name requirements to match HTML5 → Relax createElement tag name requirements to match HTML5 parser
Is that a bug in HTML5 parser or could we perhaps change HTML5 spec to not allow that? What would be the reason to allow "a<b" elements?
The DOM specifications are very clear here, and there's no reason to break them.
Status: NEW → RESOLVED
Closed: 15 years ago
OS: Mac OS X → All
Hardware: x86 → All
Resolution: --- → INVALID
The reason to allow it is that anything that the HTML5 parser can create, you should be able to create with createElement. Changing the HTML5 parser instead would probably make more sense.
(In reply to comment #3) > The reason to allow it is that anything that the HTML5 parser can create, you > should be able to create with createElement. Why, though? (Not a rhetorical question; I'd really like to know.) > Changing the HTML5 parser instead would probably make more sense. That's bug 510252.
It's already annoying enough that not every document can be serialized to HTML or XML. Making it so some documents cannot be serialized as scripts would break my mind.
That was already possible with the old parser. See this example: <http://software.hixie.ch/utilities/js/live-dom-viewer/saved/395> (that's U+00D7).
You left out the appendChild call. But yeah, you're right. <!DOCTYPE html> <body>... <a×> <script> document.body.appendChild(document.createElement("a×")); </script>
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.