Page MenuHomePhabricator

'commentMeta' nodes appearing as direct children of 'tableRow' / 'list' nodes, which breaks editing of those tables/lists
Open, Needs TriagePublic

Assigned To
None
Authored By
Tgr
Mar 12 2018, 11:58 PM
Referenced Files
F15540918: image.png
Mar 15 2018, 9:55 PM
F15506293: image.png
Mar 15 2018, 1:51 PM
F15505654: image.png
Mar 15 2018, 1:43 PM

Description

HTML comments between table cells or list items can end up as 'commentMeta' nodes appearing as direct children of 'tableRow' / 'list' nodes, which breaks editing of those tables/lists. You can still type in them, but various structural operations blow up or have unexpected results.

For example with these wikitext inputs:

* 1
<!-- foo -->
* 2
{|
|1
<!-- foo -->
|2
|}

Example broken operations:

  • Select the list and use List → Bullet list from the toolbar to unwrap it – causes an exception
  • Select table cell 1 and use Column → Move after – the cell disappears

Original description:

Steps to reproduce:

  • go to https://www.mediawiki.org/wiki/Manual:Hooks
  • edit in VE (I did it as an anonymous user; I get a different error when logged in, but that might be a gadget issue)
  • add a new table row below some existing row in the big table.

If the row is not the top of its block the new row appears but you get

VM117:222 Uncaught TypeError: Cannot read property 'getOwner' of null
    at <anonymous>:222:903
    at Array.map (<anonymous>)
    at VeCeMWTableNode.ve.ce.MWTableNode.getTablesorterHeaderCells (<anonymous>:222:860)
    at VeCeMWTableNode.ve.ce.MWTableNode.updateSortableHeaders (<anonymous>:222:221)
    at later (load.php?debug=false&lang=en&modules=oojs-ui-core%2Coojs-ui-widgets&skin=vector&version=0pbg0d6:3)

If the row is on the top of the block the new row does not appear and you get

Uncaught TypeError: Cannot read property 'node' of null
    at VeUiTableAction.ve.ui.TableAction.insertRowOrCol (load.php?debug=false&lang=en&modules=ext.CodeMirror.lib|ext.visualEditor.core&skin=vector&version=12jvj8k:905)
    at VeUiTableAction.ve.ui.TableAction.insert (load.php?debug=false&lang=en&modules=ext.CodeMirror.lib|ext.visualEditor.core&skin=vector&version=12jvj8k:895)
    at VeUiSurface.ve.ui.Surface.execute (load.php?debug=false&lang=en&modules=ext.CodeMirror.lib|ext.visualEditor.core&skin=vector&version=12jvj8k:814)
    at VeUiCommand.ve.ui.Command.execute (load.php?debug=false&lang=en&modules=ext.CodeMirror.lib|ext.visualEditor.core&skin=vector&version=12jvj8k:841)
    at VeUiInsertRowOrColumnContextItem.ve.ui.TableLineContextItem.onActionButtonClick (load.php?debug=false&lang=en&modules=ext.CodeMirror.lib|ext.visualEditor.core&skin=vector&version=12jvj8k:921)
    at OoUiButtonWidget.oo.EventEmitter.emit (<anonymous>:8:445)
    at OoUiButtonWidget.OO.ui.mixin.ButtonElement.onClick (load.php?debug=false&lang=en&modules=oojs-ui-core%2Coojs-ui-widgets&skin=vector&version=0pbg0d6:25)
    at HTMLAnchorElement.dispatch (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1sg7377:69)
    at HTMLAnchorElement.elemData.handle (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1sg7377:66)

Note the page uses Translate; doesn't seem related though.

Event Timeline

Something freaky is going on, ve.dm.TableMatrix seems to think that some of that table's rows have 5 cells instead of 4.

image.png (244×829 px, 48 KB)

Seems to be caused by the comments like <!-- linkable anchor --> at the beginning of table rows.

Simpler example:

{| class="wikitable sortable"
!A
!B
!C
|- <!-- foo -->
|1
|2
|3
|-
|4
|5
|6
|-
|7
|8
|9
|- <!-- bar -->
|10
|11
|12
|-
|13
|14
|15
|}

In VE, these comments become commentMeta nodes, and it seems we can't handle them inside tables.

image.png (574×299 px, 40 KB)

matmarex renamed this task from VisualEditor: "Cannot read property 'node' of null" when editing table with merged rows (rowspan > 1) to VisualEditor: "Cannot read property 'node' of null" when editing table with HTML comments between table cells.Mar 15 2018, 1:51 PM

A very similar issue happens with lists with HTML comments between list items:

* foo
<!-- foo -->
* bar

image.png (209×300 px, 12 KB)

Trying to unwrap this list (turn it into paragraphs of text) causes Error: listItem must be a ve.dm.ListItemNode.

matmarex renamed this task from VisualEditor: "Cannot read property 'node' of null" when editing table with HTML comments between table cells to 'commentMeta' nodes appearing as direct children of 'tableRow' / 'list' nodes, which breaks editing of those tables/lists.Mar 15 2018, 10:15 PM
matmarex updated the task description. (Show Details)

https://gerrit.wikimedia.org/r/#/c/419145/ adds some test cases for this, I'm not planning to work on it further right now.