Subramanya Sastry has uploaded a new change for review.

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

Change subject: T107652: Don't strip <ref> span tags in templated <td>-attr 
scenarios
......................................................................

T107652: Don't strip <ref> span tags in templated <td>-attr scenarios

* The dom pass that handled templated <td>-attr scenarios would
  occasionally strip <span> tags around references.

* This patch fixes that and addes a test to prevent future regressions.

Change-Id: If45880e49b3e7e5eae1943c799bebc7859f60a14
---
M lib/dom.t.TableFixups.js
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/55/228855/1

diff --git a/lib/dom.t.TableFixups.js b/lib/dom.t.TableFixups.js
index bb94c9f..c270440 100644
--- a/lib/dom.t.TableFixups.js
+++ b/lib/dom.t.TableFixups.js
@@ -118,6 +118,7 @@
        // Save the new data-mw on the tdNode
        DU.setDataMw(tdNode, { parts: parts });
        dp.pi = childDP.pi;
+       DU.setDataMw(child, undefined);
 
        // tdNode wraps everything now.
        // Remove template encapsulation from here on.
@@ -127,10 +128,18 @@
        // with some modifications.
        while (child) {
                if (child.nodeName === 'SPAN' && child.getAttribute('about') 
=== aboutId) {
-                       var next = child.firstChild || child.nextSibling;
-                       DU.migrateChildren(child, tdNode, child);
-                       DU.deleteNode(child);
-                       child = next;
+                       // Remove the encapsulation attributes. If there are no 
more attributes left,
+                       // the span wrapper is useless and can be removed.
+                       child.removeAttribute('about');
+                       child.removeAttribute('typeof');
+                       if (child.attributes.length === 0) {
+                               var next = child.firstChild || 
child.nextSibling;
+                               DU.migrateChildren(child, tdNode, child);
+                               DU.deleteNode(child);
+                               child = next;
+                       } else {
+                               child = child.nextSibling;
+                       }
                } else {
                        child = child.nextSibling;
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If45880e49b3e7e5eae1943c799bebc7859f60a14
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to