Esanders has uploaded a new change for review.

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

Change subject: ElementLinearData: Add another case to hasContent
......................................................................

ElementLinearData: Add another case to hasContent

While a document consisting of just an internalList shouldn't
be shown to the user, it might be an intermedidate state when
apply a sequence of transactions.

Change-Id: Ieeea5fab956e895bb69feab52a5d6ddfd3e18645
---
M src/dm/lineardata/ve.dm.ElementLinearData.js
M tests/dm/lineardata/ve.dm.ElementLinearData.test.js
2 files changed, 14 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/00/249800/1

diff --git a/src/dm/lineardata/ve.dm.ElementLinearData.js 
b/src/dm/lineardata/ve.dm.ElementLinearData.js
index 868de3f..a91831b 100644
--- a/src/dm/lineardata/ve.dm.ElementLinearData.js
+++ b/src/dm/lineardata/ve.dm.ElementLinearData.js
@@ -1133,5 +1133,10 @@
        // For performance, abort the count when we reach 3.
        return this.countNonInternalElements( 3 ) > 2 ||
                // Also check that the element is not a content branch node, 
e.g. a blockImage
-               ( this.isElementData( 0 ) && 
!ve.dm.nodeFactory.canNodeContainContent( this.getType( 0 ) ) );
+               // and also that is not the internal list
+               (
+                       this.isElementData( 0 ) &&
+                       !ve.dm.nodeFactory.canNodeContainContent( this.getType( 
0 ) ) &&
+                       !ve.dm.nodeFactory.isNodeInternal( this.getType( 0 ) )
+               );
 };
diff --git a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js 
b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
index 9ec66a7..ce8913a 100644
--- a/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
+++ b/tests/dm/lineardata/ve.dm.ElementLinearData.test.js
@@ -1648,6 +1648,14 @@
                        },
                        {
                                data: [
+                                       { type: 'internalList' },
+                                       { type: '/internalList' }
+                               ],
+                               expected: false,
+                               msg: 'Internal list only document has no 
content'
+                       },
+                       {
+                               data: [
                                        { type: 'paragraph' },
                                        { type: '/paragraph' },
                                        { type: 'internalList' },

-- 
To view, visit https://gerrit.wikimedia.org/r/249800
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieeea5fab956e895bb69feab52a5d6ddfd3e18645
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to