Page MenuHomePhabricator

Can't copy a selection that ends in a block node (Uncaught TypeError: Cannot read property 'isWrapped' of null)
Closed, ResolvedPublic

Description

  1. Create a VE standalone page with
Foo
<div rel="ve:Alien" style="height: 75px; width: 200px;">Alien</div>

(or a block template in Mediawiki)

  1. Select from inside "Foo" to the block template
  2. Observe the range is [2,6]. The block node's range in [5,7], so this is already problematic.
  3. Try to copy, an exception is thrown.

https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2020.08.04/clienterror/?id=AXO31qy6NoG2jwpwlCI2

Seen on https://www.mediawiki.org/wiki/Topic:Vr7vy8dfi6lopv8l

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Here is the offending loop:

ve.dm.Document.prototype.shallowCloneFromRange
while ( !endNode.isWrapped() ) {
	endNode = endNode.getParent();
}

This happens when a particular selection is copied (unclear what), but the worst that can happen is the copy doesn't work.

Reproduced with one of the cases from the log, but can also be reproduced in standalone.

  1. Open aliens.html
  2. Create a selection starting in text and ending in a block alien
  3. Hit copy with the console open and observe the error
Esanders renamed this task from Uncaught TypeError: Cannot read property 'isWrapped' of null to Can't copy a selection that ends in a block node (Uncaught TypeError: Cannot read property 'isWrapped' of null).Aug 28 2020, 4:00 PM
Esanders updated the task description. (Show Details)

Bisect somewhat unhelpfully blames this on this commit from 2014 where I got rid of the shields code and replaced it with getClientRects: https://gerrit.wikimedia.org/r/c/VisualEditor/VisualEditor/+/139805

Basically this bug has been present ever since we moved to the current way of dealing with block nodes in the surface.

Change 623025 had a related patch set uploaded (by Esanders; owner: Esanders):
[VisualEditor/VisualEditor@master] ve.dm.Document: Fix shallowCloneFromRange when range is inside alien

https://gerrit.wikimedia.org/r/623025

Change 623025 merged by jenkins-bot:
[VisualEditor/VisualEditor@master] ve.dm.Document: Fix shallowCloneFromRange when range is inside alien

https://gerrit.wikimedia.org/r/623025

Change 623655 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (15186ed26)

https://gerrit.wikimedia.org/r/623655

Change 623655 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (15186ed26)

https://gerrit.wikimedia.org/r/623655