A question about Range#insertNode

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

A question about Range#insertNode

Ms2ger
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Anne,

Step 7 of <https://dom.spec.whatwg.org/#concept-range-insert> reads

> If /range/’s start node is a Text node, split it with offset
> /range/’s start offset, set /referenceNode/ to the result, and set
> /parent/ to /referenceNode/’s parent.

In this case, /referenceNode/ has been set to /range/’s start node
(step 3), and /parent/ has been set to /referenceNode/’s parent (step
5). The split algorithm returns a node with the same parent as its
argument, so I believe that this step doesn't actually change /parent/.

Could you confirm and maybe add a note to the spec here?

Thanks
Ms2ger
-----BEGIN PGP SIGNATURE-----

iQEcBAEBAgAGBQJVm654AAoJEOXgvIL+s8n26b8H+gKfVZ6mHIaL6LcK5kvhJ/Cj
RRE64Q3YAy9mmgm/OW6fR2hLFhbbQaa8HJ86eYOBNQF73C4MT6MIC+1PMc31sPY1
JSeQTcjkgSJXSW4N2hTymT5bNyF2C/03uzJcrxUA9mVBiWJsWEUTqDGU2k4zlC2D
/vr/cF112VR64ttJz8Ru0FSR0m5faGDL6hkcWl6Hi5tE7RCcHPZzo4InlpGzZ5zP
C27563mv01Ia8FUHbEqVmr9HU1DDcZs12j55kSv6jE3fku4aAqbbJ5XDkqlD3TTQ
c0tHKnZ8gIwJOJG9Cb510eKrcSoflACNAPov/gMulpSJLkdVURHeLwj12H2K18k=
=hsv/
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: A question about Range#insertNode

Anne van Kesteren-4
On Tue, Jul 7, 2015 at 12:48 PM, Ms2ger <[hidden email]> wrote:

> Step 7 of <https://dom.spec.whatwg.org/#concept-range-insert> reads
>
>> If /range/’s start node is a Text node, split it with offset
>> /range/’s start offset, set /referenceNode/ to the result, and set
>> /parent/ to /referenceNode/’s parent.
>
> In this case, /referenceNode/ has been set to /range/’s start node
> (step 3), and /parent/ has been set to /referenceNode/’s parent (step
> 5). The split algorithm returns a node with the same parent as its
> argument, so I believe that this step doesn't actually change /parent/.
>
> Could you confirm and maybe add a note to the spec here?

You mean removing setting /parent/ again? Seems conrrect. I wonder if
Aryeh has a second to take a look since I believe he wrote that
algorithm.


--
https://annevankesteren.nl/

Reply | Threaded
Open this post in threaded view
|

Re: A question about Range#insertNode

Aryeh Gregor-4
Looks like you're correct, that bit should be removed.  If you update
the test to match the new algorithm (assuming I wrote a test for it,
I'm pretty sure I did) and it doesn't change which browsers pass, then
we could be extra super sure.  :)

On Tue, Jul 7, 2015 at 4:27 PM, Anne van Kesteren <[hidden email]> wrote:

> On Tue, Jul 7, 2015 at 12:48 PM, Ms2ger <[hidden email]> wrote:
>> Step 7 of <https://dom.spec.whatwg.org/#concept-range-insert> reads
>>
>>> If /range/’s start node is a Text node, split it with offset
>>> /range/’s start offset, set /referenceNode/ to the result, and set
>>> /parent/ to /referenceNode/’s parent.
>>
>> In this case, /referenceNode/ has been set to /range/’s start node
>> (step 3), and /parent/ has been set to /referenceNode/’s parent (step
>> 5). The split algorithm returns a node with the same parent as its
>> argument, so I believe that this step doesn't actually change /parent/.
>>
>> Could you confirm and maybe add a note to the spec here?
>
> You mean removing setting /parent/ again? Seems conrrect. I wonder if
> Aryeh has a second to take a look since I believe he wrote that
> algorithm.
>
>
> --
> https://annevankesteren.nl/

Reply | Threaded
Open this post in threaded view
|

Re: A question about Range#insertNode

Anne van Kesteren-4
On Wed, Jul 8, 2015 at 1:02 PM, Aryeh Gregor <[hidden email]> wrote:
> Looks like you're correct, that bit should be removed.  If you update
> the test to match the new algorithm (assuming I wrote a test for it,
> I'm pretty sure I did) and it doesn't change which browsers pass, then
> we could be extra super sure.  :)

It seems there's already quite some divergence between your reference
implementation and the specification :-/ Though when I removed the
line about throwing for detached ranges, nothing broke...


--
https://annevankesteren.nl/

Reply | Threaded
Open this post in threaded view
|

Re: A question about Range#insertNode

Anne van Kesteren-4
On Thu, Jul 9, 2015 at 4:56 PM, Anne van Kesteren <[hidden email]> wrote:
> On Wed, Jul 8, 2015 at 1:02 PM, Aryeh Gregor <[hidden email]> wrote:
>> Looks like you're correct, that bit should be removed.  If you update
>> the test to match the new algorithm (assuming I wrote a test for it,
>> I'm pretty sure I did) and it doesn't change which browsers pass, then
>> we could be extra super sure.  :)
>
> It seems there's already quite some divergence between your reference
> implementation and the specification :-/ Though when I removed the
> line about throwing for detached ranges, nothing broke...

I have updated the specification meanwhile, still unsure about what
would have to be changed to the test:

https://github.com/whatwg/dom/commit/4c0fb2a7c2d80d34e931f1ffd9fe85b18ab5a49c


--
https://annevankesteren.nl/