Open
Bug 843881
Opened 12 years ago
Updated 2 years ago
createElement image returns HTMLElement instead of HTMLUnknownElement
Categories
(Core :: DOM: Core & HTML, defect, P5)
Tracking
()
NEW
People
(Reporter: erik, Unassigned)
Details
The following fails
assert(document.createElement('image').constructor === HTMLImageElement);
assert(document.createElement('image').constructor !== HTMLSpanElement);
It is really confusing to get an HTMLSpanElement out of this
We've had this behavior for a decade. Not really sure why.
Maybe we used to use span for what now is just a generic html element?
Comment 3•12 years ago
|
||
Henri might remember.
image is odd element.
Comment 4•12 years ago
|
||
"image" is not special for purposes of createElement. It's just like "foo" or "xyzw" or "noSuchElementName".
So we should be creating an HTMLUnknownElement here, as far as I can tell (but aren't, for silly historical reasons that predate the existence of HTMLUnknownElement as I recall). We should consider going through nsHTMLTagList.h and fixing up the various things that claim "Span" for the second argument; some of these should be HTMLUnknownElement and some apparently actually have interfaces for them in HTML5 (basefont???).
Whiteboard: [mentor=bz][lang=c++][good first bug]
Comment 5•12 years ago
|
||
(In reply to Erik Arvidsson from comment #0)
> The following fails
>
> assert(document.createElement('image').constructor === HTMLImageElement);
This should fail. That it doesn't is a bug in WebKit.
Updated•12 years ago
|
OS: Linux → All
Hardware: x86_64 → All
Comment 6•12 years ago
|
||
(In reply to :Ms2ger from comment #5)
> (In reply to Erik Arvidsson from comment #0)
> > The following fails
> >
> > assert(document.createElement('image').constructor === HTMLImageElement);
>
> This should fail. That it doesn't is a bug in WebKit.
document.createElement("image"); results in an HTMLImageElement in IE10, too. Maybe we should just align instead of fighting it. Need more testing first to see if such elements actually work in WebKit and IE.
OS: All → Linux
Hardware: All → x86_64
Comment 7•12 years ago
|
||
ccing Anne, since this would need domcore spec changes to create an element with localName "img" when createElement("image") is called... At least that's what WebKit does, so I would expect that it "works" just fine once created.
Comment 8•12 years ago
|
||
Not just createElement() it seems. :-(
http://software.hixie.ch/utilities/js/live-dom-viewer/
<script>w(document.createElementNS("http://www.w3.org/1999/xhtml", "image"))</script>
Maybe the conceptual model should be that the local name and namespace are decided by the class that is mapped to. Might also work better for custom elements.
Comment 9•12 years ago
|
||
> Not just createElement() it seems. :-(
Just in WebKit, or in IE10 too?
Comment 10•12 years ago
|
||
IE9 at least, cannot test IE10.
Comment 11•12 years ago
|
||
So maybe we should spin off a separate bug on our use of "Span" when we should use "Unknown", independent of what happens with the "image" mess? Or spin the "image" mess into a separate bug, either way.
Comment 12•12 years ago
|
||
Filed bug 844127 on Span vs Unknown. Removing good first bug flags as we first need to decide whether we want the "image" "magic" or not.
Whiteboard: [mentor=bz][lang=c++][good first bug]
Updated•6 years ago
|
Priority: -- → P5
Updated•6 years ago
|
Summary: createElement image returns HTMLSpanElement → createElement image returns HTMLElement instead of HTMLUnknownElement
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•