This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 15350 - Range.insertNode() into the middle of a comment
Summary: Range.insertNode() into the middle of a comment
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-27 20:25 UTC by Aryeh Gregor
Modified: 2011-12-28 17:15 UTC (History)
2 users (show)

See Also:


Attachments

Description Aryeh Gregor 2011-12-27 20:25:43 UTC
Test-case:

data:text/html,<!DOCTYPE html>
<script>
var range = document.createRange();
document.head.appendChild(document.createComment("abc"));
range.setStart(document.head.lastChild, 2);
range.insertNode(document.createTextNode("def"));
</script>

Firefox 12.0a1 and Chrome 17 dev throw HierarchyRequestError.  Opera Next 12.00 alpha splits the comment node, like <!--ab-->def<!--c-->.  I don't have IE handy to test -- could someone tell me what it does?  The spec says to insert the new text node immediately before the comment node, so you get something like def<!--abc-->.

Throwing seems much saner than what the spec says.  is there any reason not to change the spec to require that, like Gecko/WebKit (and maybe IE too for all I know)?  I don't know why I specced it this way to start with . . .
Comment 1 Anne 2011-12-28 09:25:23 UTC
IE9 throws an exception too (the same).