This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26609 - AttrExodus: investigate child nodes of attributes and attributes being nodes
Summary: AttrExodus: investigate child nodes of attributes and attributes being nodes
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-19 20:59 UTC by Anne
Modified: 2015-11-11 14:46 UTC (History)
5 users (show)

See Also:


Attachments

Description Anne 2014-08-19 20:59:15 UTC
As a first step investigate what various browsers support. Then investigate what could be simplified in the model if they dropped support for those features. Then investigate whether those features could be dropped if worthwhile.
Comment 1 Anne 2014-08-20 11:36:23 UTC
Gecko throws when you attempt to mutate an attribute's children and acts as if an attribute has no children. E.g. attr.firstChild returns null. attr.appendChild() throws a "HierarchyRequestError".

Chrome allows mutating attribute children. Inserting a text node modifies both the inserted text node and the text node already present.

IE10 throws just like Gecko. However, it does pretend there is either no child or a single text node child.

Hopefully Chrome can start throwing for mutation. And hopefully it can even emulate Gecko in not exposing any children.

(I'm assuming Safari is the same as Chrome here.)


Now if these methods simply throw, removing them should be possible so there's still hope for attributes not being nodes I think.
Comment 2 Philip Jägenstedt 2014-08-20 11:56:38 UTC
In Gecko, how can you attempt to mutate the children if it has no children?

If we can end up with Attr as a child-free Node type like Text it would be great. Beyond that, is there simplification to be had for making it not a Node at all?
Comment 3 Anne 2014-08-20 12:48:00 UTC
Well you can attempt to use things like appendChild() and see them fail. 

If they are not nodes they do not have all the concepts associated with nodes: base URL, node document, cloning, adopting, ... Other algorithms do not have to worry about them.
Comment 4 Arkadiusz Michalski (Spirit) 2014-11-18 15:42:35 UTC
It looks that these old property are often used for attributes:
https://www.chromestatus.com/metrics/feature/timeline/popularity/348

more then Attr.textContent and Attr.ownerElement (which was added to the interface Attr):
https://www.chromestatus.com/metrics/feature/timeline/popularity/349
https://www.chromestatus.com/metrics/feature/timeline/popularity/160
Comment 5 Philip Jägenstedt 2014-11-18 22:15:48 UTC
Given that Attr has no children in Gecko, I guess that Attr.textContent overrides Node.textContent to instead be an alias of value?
Comment 6 Philip Jägenstedt 2014-11-18 23:03:18 UTC
Use counters for the access and modification of Attr's child Text nodes in Blink:
https://codereview.chromium.org/723393005/

If the usage is low, hopefully Blink can align with Gecko as a first step. textContent would need special casing, though.
Comment 7 Anne 2014-11-19 07:51:45 UTC
textContent is already changed in the specification. Am I missing something?
Comment 8 Philip Jägenstedt 2014-11-19 08:12:41 UTC
Ah, I didn't know you'd changed the spec. Ignore me :)
Comment 9 Philip Jägenstedt 2015-02-21 18:28:06 UTC
Blink bug tracking this:
https://code.google.com/p/chromium/issues/detail?id=305105
Comment 10 Philip Jägenstedt 2015-05-25 20:48:09 UTC
A potential problem was raised on public-html:
https://lists.w3.org/Archives/Public/public-html/2015May/thread.html#msg90

If Attr.cloneNode() is in common use as a workaround for setAttribute() being stricter than the HTML parser, that could complicate the effort to make Attr not inherit from Node.
Comment 11 Anne 2015-11-11 14:46:05 UTC
https://github.com/whatwg/dom/issues/102 covers this fine.