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

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: Have Attr track local name of attached attribute, if needed. 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
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index e578bc18e6a599d09a368b53145ef9c777b75f90..9750499c5762dc16a0179fbeedaaf10a3799f150 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1894,16 +1894,25 @@ PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNode(Attr* attrNode, Exception
UniqueElementData& elementData = ensureUniqueElementData();
size_t index = elementData.getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase());
+ AtomicString localName;
if (index != kNotFound) {
+ 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(), elementData.attributeItem(index).value());
+ detachAttrNodeFromElementWithValue(oldAttrNode.get(), attr.value());
else
- oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData.attributeItem(index).value());
+ 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);
« LayoutTests/fast/dom/Attr/update-attribute-node-no-crash.html ('K') | « Source/core/dom/Attr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698