[Bug 12389] New: replaceWholeText should not remove the context node, just change its data

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12389

           Summary: replaceWholeText should not remove the context node,
                    just change its data
           Product: WebAppsWG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DOM Core
        AssignedTo: annevk@opera.com
        ReportedBy: Simetrical+w3cbug@gmail.com
         QAContact: member-webapi-cvs@w3.org
                CC: mike@w3.org, www-dom@w3.org


The current spec says

"""
The replaceWholeText(data) method must run these steps:

  1. Remove the contiguous Text nodes of the context object.

  2. If data is not the empty string, insert a new Text node whose data is data
at the place of the removed nodes, return the new Text node, and then terminate
these steps.

  3. Return null.
"""

But in fact browsers don't remove the node itself, they only remove siblings. 
Test case:

data:text/html,<!doctype html>
<p>Abc</p>
<script>
var original = document.querySelector("p").firstChild;
document.body.textContent = original.replaceWholeText("Def") == original;
</script>

Results in "true" in Firefox 4.0, Chrome 11 dev, and Opera 11.  (I didn't have
IE available for easy testing.)  The spec should say that if data is not the
empty string, the contiguous Text nodes of the context objects must be removed
except for the context object itself, then the context object's data should be
set and the method should return the context object.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Monday, 28 March 2011 17:41:38 UTC