diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 52905d5016b5cc2770266aa737b01743a91daee6..732b7f237cc4b350a3f46e986cc6fe9c2aa40c85 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2008-05-14 Michael A. Puls II + + Reviewed by Alexey. + + Test for https://bugs.webkit.org/show_bug.cgi?id=16923 + + Test that Attr nodes with a value of "" don't have any + childNodes like Firefox, Opera and IE. + + * fast/dom/attribute-empty-value-no-children-expected.txt: Added. + * fast/dom/attribute-empty-value-no-children.html: Added. + 2008-05-13 Dan Bernstein Reviewed by John Sullivan. diff --git a/LayoutTests/fast/dom/attribute-empty-value-no-children-expected.txt b/LayoutTests/fast/dom/attribute-empty-value-no-children-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..856efeae4ead20255d49c83072fdb35480f8e180 --- /dev/null +++ b/LayoutTests/fast/dom/attribute-empty-value-no-children-expected.txt @@ -0,0 +1,17 @@ +Attr empty value tests Bug 16923 + +In Opera, Firefox and IE, when an Attr's value is an empty string, the Attr node won't have any childNodes. The following 12 tests will see if this is true for WebKit for both parsed and dynamically-created Attr nodes. The tests use multiple methods of changing the Attr's value and even test reverting from a non-empty value to an empty one to check that all childNodes were removed. Some of the tests make use of .textContent, so this test is not compatible with IE. Opera and Firefox both completely pass this test. + +SubTest 1 = PASS +SubTest 2 = PASS +SubTest 3 = PASS +SubTest 4 = PASS +SubTest 5 = PASS +SubTest 6 = PASS +SubTest 7 = PASS +SubTest 8 = PASS +SubTest 9 = PASS +SubTest 10 = PASS +SubTest 11 = PASS +SubTest 12 = PASS +Complete Test = PASS diff --git a/LayoutTests/fast/dom/attribute-empty-value-no-children.html b/LayoutTests/fast/dom/attribute-empty-value-no-children.html new file mode 100644 index 0000000000000000000000000000000000000000..a8b62eb184d9937c2da647ce81a10d6671806843 --- /dev/null +++ b/LayoutTests/fast/dom/attribute-empty-value-no-children.html @@ -0,0 +1,92 @@ + + + + Attr empty value tests + + + +

Attr empty value tests Bug 16923

+

In Opera, Firefox and IE, when an Attr's value is an empty string, the Attr node won't have any childNodes. The following 12 tests will see if this is true for WebKit for both parsed and dynamically-created Attr nodes. The tests use multiple methods of changing the Attr's value and even test reverting from a non-empty value to an empty one to check that all childNodes were removed. Some of the tests make use of .textContent, so this test is not compatible with IE. Opera and Firefox both completely pass this test.

+

This test requires Javascript.

+ + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 0f4bdb996745e53fb176eeeacd770874706cd139..d1fe84a8c123460ef2eb0a925374497ef75755f9 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,20 @@ +2008-05-14 Michael A. Puls II + + Reviewed by Alexey. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=16923 + Attr nodes with a value of "" should not have any childNodes + + In Opera, Firefox and IE, when an attribute node has a value + of "", the attribute node doesn't have any childNodes. This + is true in WebKit also, but not when you assign "" to the + Attr's value when the existing value is non-empty. + + Test: fast/dom/attribute-empty-value-no-children.html + + * dom/Attr.cpp: (WebCore::Attr::setValue): Use createTextChild(), which only appends + a child text node if the value being assigned is not empty. + 2008-05-14 Julien Chaffraix Reviewed by Eric. diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp index 52a25818853599746dd078e4b40345aecca305e9..c93462f4b3d68f86d9db7d31590668490ba5e7e0 100644 --- a/WebCore/dom/Attr.cpp +++ b/WebCore/dom/Attr.cpp @@ -105,7 +105,7 @@ void Attr::setValue( const String& v, ExceptionCode& ec) { ec = 0; - // do not interprete entities in the string, its literal! + // do not interpret entities in the string, it's literal! // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly if (isReadOnlyNode()) { @@ -113,13 +113,12 @@ void Attr::setValue( const String& v, ExceptionCode& ec) return; } - int e = 0; m_ignoreChildrenChanged++; removeChildren(); - appendChild(document()->createTextNode(v), e); - m_ignoreChildrenChanged--; - m_attribute->setValue(v.impl()); + createTextChild(); + m_ignoreChildrenChanged--; + if (m_element) m_element->attributeChanged(m_attribute.get()); }