- From: Lynn Monson <lmonson@flipdog.com>
- Date: Tue, 24 Oct 2000 15:17:12 -0600
- To: <www-dom@w3.org>
I'm looking for clarification on how DOM 2 Ranges respond to document mutations triggered by calling Range.surroundContents. If anyone could offer some clarification, I would appreciate it. Suppose I have a text node in an XHTML document: FooBarBaz And I have two ranges, that both lie within this text node: r1: start offset=3 end offset=6 (r1 selects "Bar") r2: start offset=6 end offset=9 (r2 selects "Baz") If I attempt to bold r1 by invoking r1.surroundContents() with a <b/> element, I get the following result: Foo<b>Bar</b>Baz It's clear from the DOM 2 spec that r1 then selects <b>Bar</b>, but I'm not certain what r2 selects. If I read section 2.10 literally, performing surroundContents in terms of other operations, and letting r2 respond to each mutation event, I wind up with r2 as follows: r2: start container: Foo start offset: 3 end container: Baz end offset: 3 (r2 selects from the end of Foo, through <b>Bar</b>, to the end of Baz) It seems counter intuitive that r2 would "jump" to include the (now bolded) "Bar" text. In addition it seems to violate the principle stated in section 2.12 of the DOM 2 spec: "There are two general principles which apply to Ranges under document mutation: ... the second is that, as much as possible, all Ranges will select the same portion of the document after any mutation operation." That would seem to imply that since my outermost operation was r1.surroundContents, r2 ought to select "Baz" as it did before. Have I read section 2.10 correctly? If so, this seems in violation of 2.12. Given that I have multiple Ranges, I'm not certain if a literal reading of section 2.10 produces the right outcome. Could anyone clarify what was intended? Thanks for any feedback Lynn Monson
Received on Tuesday, 24 October 2000 17:22:15 UTC