DescriptionNever cast Attr to ContainerNode based on nodeType ATTRIBUTE_NODE
In https://codereview.chromium.org/1158433004 Attr began inheriting from
Node instead of ContainerNode, but there remained cases where
toContainerNode() was called for Attr.
All instances of toContainerNode() and other casts to ContainerNode were
inspected and only these two were found to be problematic, although some
instances in core/editing are non-obvious.
Because textContent is an alias of value in Attr.idl, web content
setting attr.textContent directly will not take the Node code path in
question. However, it is possible with some effort:
var attr = document.createAttribute("name");
Object.getOwnPropertyDescriptor(Node.prototype, "textContent").set.call(attr, "value");
This will now do nothing, and the equivalent code with the getter would
already return null before this change. This is strange, but most
closely resembles the spec, which doesn't handle Attr in the textContent
setter because per spec it isn't a Node at all:
https://dom.spec.whatwg.org/#dom-node-textcontent
No calls to Node::textContent() or Node::setTextContent() where the Node
could be an Attr were found, other than V8Node.cp in generated bindings.
BUG=305105, 494043
TEST=Source/core/dom/AttrTest.cpp (also tests nodeValue)
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=196452
Patch Set 1 #Patch Set 2 : write unit test #Patch Set 3 : new deal: setTextContent(attr) does nothing #
Messages
Total messages: 21 (7 generated)
|