jenkins-bot has submitted this change and it was merged.

Change subject: Fix reordering of metadata bug
......................................................................


Fix reordering of metadata bug

If you had <meta /><b>Annotated text</b> in a wrapper paragraph,
the converter would swap them and output the linear model equivalent
of <p wrapper><b>Annotated text</b></p><meta />.

This happened because the meta item was queued, and annotations didn't
trigger metadata queue flushes. The fix is to trigger a metadata queue
flush whenever we're about to write something that isn't itself queued.

Change-Id: I168abc0392fbec5503271d1653ee5c38518f857d
---
M modules/ve/dm/ve.dm.Converter.js
M modules/ve/test/dm/ve.dm.example.js
2 files changed, 26 insertions(+), 0 deletions(-)

Approvals:
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/dm/ve.dm.Converter.js b/modules/ve/dm/ve.dm.Converter.js
index 47ed400..788f7a6 100644
--- a/modules/ve/dm/ve.dm.Converter.js
+++ b/modules/ve/dm/ve.dm.Converter.js
@@ -601,6 +601,7 @@
                                                childDataElements = 
this.createDataElements( ve.dm.AlienMetaItem, childDomElements );
                                                childDataElements.push( { 
'type': '/' + childDataElements[0].type } );
                                        }
+                                       outputWrappedMetaItems( 'restore' );
                                        data = data.concat( childDataElements );
                                        // Clear wrapped whitespace
                                        wrappedWhitespace = '';
@@ -627,6 +628,7 @@
                                                                
wrappedWhitespace = '';
                                                        }
                                                } else {
+                                                       outputWrappedMetaItems( 
'restore' );
                                                        data = data.concat( 
childDataElements );
                                                        processNextWhitespace( 
childDataElements[0] );
                                                        prevElement = 
childDataElements[0];
@@ -679,6 +681,7 @@
                                                }
                                                // Recursion
                                                // Opening and closing elements 
are added by the recursion too
+                                               outputWrappedMetaItems( 
'restore' );
                                                data = data.concat(
                                                        
this.getDataFromDomRecursion( childDomElement, childDataElements[0],
                                                                new 
ve.dm.AnnotationSet( this.store )
@@ -695,6 +698,7 @@
                                                        
childDataElements[0].htmlAttributes = htmlAttributes;
                                                }
                                                // Write childDataElements 
directly
+                                               outputWrappedMetaItems( 
'restore' );
                                                data = data.concat( 
childDataElements );
                                        }
                                        processNextWhitespace( 
childDataElements[0] );
diff --git a/modules/ve/test/dm/ve.dm.example.js 
b/modules/ve/test/dm/ve.dm.example.js
index 3525253..e6c0d11 100644
--- a/modules/ve/test/dm/ve.dm.example.js
+++ b/modules/ve/test/dm/ve.dm.example.js
@@ -1032,6 +1032,28 @@
                        { 'type': '/internalList' }
                ]
        },
+       'metadata in a wrapper followed by annotated text': {
+               'html': '<body>Foo<!--bar--><b>Baz</b></body>',
+               'data': [
+                       { 'type': 'paragraph', 'internal': { 'generated': 
'wrapper' } },
+                       'F',
+                       'o',
+                       'o',
+                       {
+                               'type': 'alienMeta',
+                               'attributes': {
+                                       'domElements': $( '<!--bar-->' 
).toArray()
+                               }
+                       },
+                       { 'type': '/alienMeta' },
+                       [ 'B', [ ve.dm.example.bold ] ],
+                       [ 'a', [ ve.dm.example.bold ] ],
+                       [ 'z', [ ve.dm.example.bold ] ],
+                       { 'type': '/paragraph' },
+                       { 'type': 'internalList' },
+                       { 'type': '/internalList' }
+               ]
+       },
        'wrapping of bare content': {
                'html': '<body>abc</body>',
                'data': [

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I168abc0392fbec5503271d1653ee5c38518f857d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to