Only attach Attributes to a given element one time
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 01:00:09 +0000 (01:00 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Mar 2017 01:00:09 +0000 (01:00 +0000)
commitee1b22e0d354a64a39bb156b04eebc2fbb026ee3
tree3e5ee58157cc00e9b0a35a03a26b1b9e0f6f0fc0
parent58235fab6c795bb980c6fb6b56de68a2797a3315
Only attach Attributes to a given element one time
https://bugs.webkit.org/show_bug.cgi?id=170125
<rdar://problem/31279676>

Reviewed by Chris Dumez.

Source/WebCore:

Attach the attribute node to the Element before calling 'setAttributeInternal', since that method may cause
arbitrary JavaScript events to fire.

Test: fast/dom/Attr/only-attach-attr-once.html

* dom/Element.cpp:
(WebCore::Element::attachAttributeNodeIfNeeded): Added.
(WebCore::Element::setAttributeNode): Use new method. Revise to attach attribute before calling 'setAttributeInternal'.
(WebCore::Element::setAttributeNodeNS): Ditto.
* dom/Element.h:

LayoutTests:

* fast/dom/Attr/make-unique-element-data-while-replacing-attr-expected.txt: Rebaselined.
* fast/dom/Attr/make-unique-element-data-while-replacing-attr.html: Add check before setting new value.
* fast/dom/Attr/only-attach-attr-once-expected.txt: Added.
* fast/dom/Attr/only-attach-attr-once.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/Attr/make-unique-element-data-while-replacing-attr-expected.txt
LayoutTests/fast/dom/Attr/make-unique-element-data-while-replacing-attr.html
LayoutTests/fast/dom/Attr/only-attach-attr-once-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Attr/only-attach-attr-once.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h