Arlolra has uploaded a new change for review.

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


Change subject: Don't emit foster box in transclusion
......................................................................

Don't emit foster box in transclusion

In 05894f170ba8e9a712099d3e6e6cd48ff53808d we removed encapsulation when
the associated table was in transclusion. This goes one step further and
avoids emitting it altogether. It shouldn't be needed and is breaking in
the odd unbalanced table situations.

Bug: 55820
Change-Id: I8424f4c3ec4de6c2b9072cb1712ae0ca4b312536
---
M js/lib/dom.markFosteredContent.js
M js/lib/mediawiki.HTML5TreeBuilder.node.js
2 files changed, 18 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/87/90287/1

diff --git a/js/lib/dom.markFosteredContent.js 
b/js/lib/dom.markFosteredContent.js
index a0b6c0b..b86233f 100644
--- a/js/lib/dom.markFosteredContent.js
+++ b/js/lib/dom.markFosteredContent.js
@@ -87,7 +87,7 @@
                if ( DU.isMarkerMeta( c, "mw:FosterBox" ) ) {
 
                        // mark as fostered until we hit the table
-                       while ( sibling && ( !DU.isElt( sibling ) || 
!DU.hasNodeName( sibling, "table" ) ) ) {
+                       while ( !DU.isElt( sibling ) || !DU.hasNodeName( 
sibling, "table" ) ) {
                                next = sibling.nextSibling;
                                if ( DU.isElt( sibling ) ) {
                                        sibling.data.parsoid.fostered = true;
@@ -101,13 +101,15 @@
                                        span.appendChild( sibling );
                                }
                                sibling = next;
+                               if ( !sibling ) {
+                                       console.log( "Table isn't a sibling. 
Something's amiss!" )
+                                       break;
+                               }
                        }
 
                        // we have fostered transclusions
                        // wrap the whole thing in a transclusion
-                       // But, skip if foster box itself is in transclusion
-                       // avoid unnecessary insertions and case where table 
doesn't have tsr info
-                       if ( fosteredTransclusions && 
!c.data.parsoid.inTransclusion ) {
+                       if ( fosteredTransclusions ) {
                                insertTransclusionMetas( env, c, sibling );
                        }
 
diff --git a/js/lib/mediawiki.HTML5TreeBuilder.node.js 
b/js/lib/mediawiki.HTML5TreeBuilder.node.js
index 9a909ba..e028240 100644
--- a/js/lib/mediawiki.HTML5TreeBuilder.node.js
+++ b/js/lib/mediawiki.HTML5TreeBuilder.node.js
@@ -211,17 +211,20 @@
                case TagTk:
                        tName = token.name;
                        if ( tName === "table" ) {
-                               if ( this.trace ) {
-                                       console.warn('inserting foster box 
meta');
-                               }
-                               attrs = [{ name: "typeof", value: 
"mw:FosterBox" }];
-                               if ( this.inTransclusion ) {
-                                       attrs.push({
-                                               name: "data-parsoid",
-                                               value: JSON.stringify({ 
inTransclusion: true })
+                               // Don't add foster box in transclusion
+                               // Avoids unnecessary insertions, the case 
where a table
+                               // doesn't have tsr info, and the messy 
unbalanced table case,
+                               // like the navbox
+                               if ( !this.inTransclusion ) {
+                                       if ( this.trace ) {
+                                               console.warn('inserting foster 
box meta');
+                                       }
+                                       this.emit('token', {
+                                               type: 'StartTag',
+                                               name: 'meta',
+                                               data: [ { name: "typeof", 
value: "mw:FosterBox" } ]
                                        });
                                }
-                               this.emit('token', { type: 'StartTag', name: 
'meta', data: attrs });
                        }
                        this.emit('token', {type: 'StartTag', name: tName, 
data: this._att(attribs)});
                        attrs = [];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8424f4c3ec4de6c2b9072cb1712ae0ca4b312536
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

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

Reply via email to