зеркало из https://github.com/mozilla/gecko-dev.git
Bug 600466 - Actually remove child when .removeChild() is called on attributes. r=bz a=blocking-2.0
This commit is contained in:
Родитель
5f4484dc05
Коммит
f2aa93a693
|
@ -672,6 +672,8 @@ nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationE
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
doRemoveChild();
|
||||
|
||||
nsString nullString;
|
||||
SetDOMStringToNull(nullString);
|
||||
SetValue(nullString);
|
||||
|
@ -777,9 +779,7 @@ nsDOMAttribute::AttributeChanged(nsIDocument* aDocument,
|
|||
|
||||
// Just blow away our mChild and recreate it if needed
|
||||
if (mChild) {
|
||||
static_cast<nsTextNode*>(mChild)->UnbindFromAttribute();
|
||||
NS_RELEASE(mChild);
|
||||
mFirstChild = nsnull;
|
||||
doRemoveChild();
|
||||
}
|
||||
EnsureChildState();
|
||||
}
|
||||
|
@ -795,3 +795,12 @@ nsDOMAttribute::Shutdown()
|
|||
{
|
||||
sInitialized = PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttribute::doRemoveChild()
|
||||
{
|
||||
static_cast<nsTextNode*>(mChild)->UnbindFromAttribute();
|
||||
NS_RELEASE(mChild);
|
||||
mFirstChild = nsnull;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,11 @@ private:
|
|||
|
||||
void EnsureChildState();
|
||||
|
||||
/**
|
||||
* Really removing the attribute child (unbind and release).
|
||||
*/
|
||||
void doRemoveChild();
|
||||
|
||||
nsString mValue;
|
||||
// XXX For now, there's only a single child - a text element
|
||||
// representing the value. This is strong ref, but we use a raw
|
||||
|
|
|
@ -423,6 +423,7 @@ _TEST_FILES2 = \
|
|||
test_createHTMLDocument.html \
|
||||
test_bug578096.html \
|
||||
test_bug598877.html \
|
||||
test_bug600466.html \
|
||||
$(NULL)
|
||||
|
||||
# This test fails on the Mac for some reason
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=600466
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 600466</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=600466">Mozilla Bug 600466</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 600466 **/
|
||||
|
||||
var attr = document.createAttribute("foo");
|
||||
attr.value = "bar";
|
||||
ok(attr.firstChild, "attr should have a first child");
|
||||
|
||||
attr.removeChild(attr.firstChild);
|
||||
ok(!attr.firstChild, "attr should not have a first child anymore");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче