Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Unified Diff: Source/core/dom/Element.cpp

Issue 316583002: Correctly handle accessing a replaced Attr object's attribute value. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add setAttributeNode() FIXME Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Attr.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index e578bc18e6a599d09a368b53145ef9c777b75f90..1f8d3da2f814b5c2e18f7c427c578c2cb2245b90 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1894,16 +1894,31 @@ PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNode(Attr* attrNode, Exception
UniqueElementData& elementData = ensureUniqueElementData();
size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase());
+ AtomicString localName;
if (index != kNotFound) {
- if (oldAttrNode)
- detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData.attributeItem(index).value());
- else
- oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData.attributeItem(index).value());
+ const Attribute& attr = elementData.attributeItem(index);
+
+ // If the name of the ElementData attribute doesn't
+ // (case-sensitively) match that of the Attr node, record it
+ // on the Attr so that it can correctly resolve the value on
+ // the Element.
+ if (!attr.name().matches(attrNode->qualifiedName()))
+ localName = attr.localName();
+
+ if (oldAttrNode) {
+ detachAttrNodeFromElementWithValue(oldAttrNode.get(), attr.value());
+ } else {
+ // FIXME: using attrNode's name rather than the
+ // Attribute's for the replaced Attr is compatible with
+ // all but Gecko (and, arguably, the DOM Level1 spec text.)
+ // Consider switching.
+ oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), attr.value());
+ }
}
setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute);
- attrNode->attachToElement(this);
+ attrNode->attachToElement(this, localName);
treeScope().adoptIfNeeded(*attrNode);
ensureAttrNodeListForElement(this).append(attrNode);
« no previous file with comments | « Source/core/dom/Attr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698