Commit backport by Michael Gilbert <michael.s.gilbert@gmail.com>
authorHuzaifa Sidhpurwala <huzaifas@redhat.com>
Tue, 8 Feb 2011 08:45:10 +0000 (14:15 +0530)
committerHuzaifa Sidhpurwala <huzaifas@redhat.com>
Tue, 8 Feb 2011 08:45:10 +0000 (14:15 +0530)
commit24710a663ea000a071208c3bc0dd7d7fd9a0e088
tree513b7b14cfe9a12590b0803afd72f4987f9638a1
parentb005f36d1aba4adc9dd75277072e940a09214a75
Commit backport by Michael Gilbert <michael.s.gilbert@gmail.com>
Add test case

            Reviewed by Adam Barth.

            https://bugs.webkit.org/show_bug.cgi?id=46222
            <rdar://problem/8461701> Document.getElementById() malfunctions if ID was changed via Attr node modification.

            Test: fast/dom/Attr/change-id-via-attr-node-value.html

            * dom/Attr.h:
            * dom/Attr.cpp:
            (WebCore::Attr::setValue): Separated a version callable from WebCore from one avaiable to JS.
            Attr::setValue() can be called from Element::setAttribute(), and we don't want to update
            m_elementsById (or to call attributeChanged()) twice in that case.
            (WebCore::Attr::childrenChanged): If Attr's node children change, id changes.

            * dom/Document.cpp: (WebCore::Document::removeElementById): Added an assertion that we are
            not trying to remove something that isn't there. If we are, we probably failed to update
            m_elementsById earlier.

            * dom/Element.cpp: (WebCore::Element::setAttribute): If the attribute has an Attr node, its
            children should be updated to match attribute value.

    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/fast/dom/Attr/change-id-via-attr-node-value-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Attr/change-id-via-attr-node-value.html [new file with mode: 0644]
WebCore/dom/Attr.cpp
WebCore/dom/Attr.h
WebCore/dom/Document.cpp
WebCore/dom/Element.cpp
WebCore/dom/Element.h