[MediaWiki-commits] [Gerrit] parserTests.js: Fix manual changes support for before/after ... - change (mediawiki...parsoid)

2016-05-30 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: parserTests.js: Fix manual changes support for before/after 
selector
..


parserTests.js: Fix manual changes support for before/after selector

* Using  for table content doesn't work since  tags can only
  be inserted in 

Change-Id: I78a534787bececb4677b12a5b8fe5b193b42809f
---
M bin/parserTests.js
1 file changed, 32 insertions(+), 6 deletions(-)

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



diff --git a/bin/parserTests.js b/bin/parserTests.js
index 8d9c2d3..788942c 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -774,17 +774,43 @@
// a good way to get at the text and comment nodes
var jquery = {
after: function(html) {
-   var div = this.ownerDocument.createElement('div');
-   div.innerHTML = html;
-   DU.migrateChildren(div, this.parentNode, 
this.nextSibling);
+   var div, tbl;
+   if (this.parentNode.nodeName === 'TBODY') {
+   tbl = this.ownerDocument.createElement('table');
+   tbl.innerHTML = html;
+   //  is implicitly added when inner html 
is set to ..
+   DU.migrateChildren(tbl.firstChild, 
this.parentNode, this.nextSibling);
+   } else if (this.parentNode.nodeName === 'TR') {
+   tbl = this.ownerDocument.createElement('table');
+   tbl.innerHTML = '';
+   tbl.firstChild.firstChild.innerHTML = html;
+   DU.migrateChildren(tbl.firstChild.firstChild, 
this.parentNode, this.nextSibling);
+   } else {
+   div = this.ownerDocument.createElement('div');
+   div.innerHTML = html;
+   DU.migrateChildren(div, this.parentNode, 
this.nextSibling);
+   }
},
attr: function(name, val) {
this.setAttribute(name, val);
},
before: function(html) {
-   var div = this.ownerDocument.createElement('div');
-   div.innerHTML = html;
-   DU.migrateChildren(div, this.parentNode, this);
+   var div, tbl;
+   if (this.parentNode.nodeName === 'TBODY') {
+   tbl = this.ownerDocument.createElement('table');
+   tbl.innerHTML = html;
+   //  is implicitly added when inner html 
is set to ..
+   DU.migrateChildren(tbl.firstChild, 
this.parentNode, this);
+   } else if (this.parentNode.nodeName === 'TR') {
+   tbl = this.ownerDocument.createElement('table');
+   tbl.innerHTML = '';
+   tbl.firstChild.firstChild.innerHTML = html;
+   DU.migrateChildren(tbl.firstChild.firstChild, 
this.parentNode, this);
+   } else {
+   div = this.ownerDocument.createElement('div');
+   div.innerHTML = html;
+   DU.migrateChildren(div, this.parentNode, this);
+   }
},
removeAttr: function(name) {
this.removeAttribute(name);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I78a534787bececb4677b12a5b8fe5b193b42809f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 
Gerrit-Reviewer: Arlolra 
Gerrit-Reviewer: Cscott 
Gerrit-Reviewer: Subramanya Sastry 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] parserTests.js: Fix manual changes support for before/after ... - change (mediawiki...parsoid)

2016-05-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review.

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

Change subject: parserTests.js: Fix manual changes support for before/after 
selector
..

parserTests.js: Fix manual changes support for before/after selector

* Using  for table content doesn't work since  tags can only
  be inserted in 

Change-Id: I78a534787bececb4677b12a5b8fe5b193b42809f
---
M bin/parserTests.js
1 file changed, 18 insertions(+), 6 deletions(-)


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

diff --git a/bin/parserTests.js b/bin/parserTests.js
index 8d9c2d3..64a0962 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -774,17 +774,29 @@
// a good way to get at the text and comment nodes
var jquery = {
after: function(html) {
-   var div = this.ownerDocument.createElement('div');
-   div.innerHTML = html;
-   DU.migrateChildren(div, this.parentNode, 
this.nextSibling);
+   if (this.parentNode.nodeName === 'TBODY') {
+   var tbl = 
this.ownerDocument.createElement('table');
+   tbl.innerHTML = html;
+   DU.migrateChildren(tbl.firstChild, 
this.parentNode, this.nextSibling);
+   } else {
+   var div = 
this.ownerDocument.createElement('div');
+   div.innerHTML = html;
+   DU.migrateChildren(div, this.parentNode, 
this.nextSibling);
+   }
},
attr: function(name, val) {
this.setAttribute(name, val);
},
before: function(html) {
-   var div = this.ownerDocument.createElement('div');
-   div.innerHTML = html;
-   DU.migrateChildren(div, this.parentNode, this);
+   if (this.parentNode.nodeName === 'TBODY') {
+   var tbl = 
this.ownerDocument.createElement('table');
+   tbl.innerHTML = html;
+   DU.migrateChildren(tbl.firstChild, 
this.parentNode, this);
+   } else {
+   var div = 
this.ownerDocument.createElement('div');
+   div.innerHTML = html;
+   DU.migrateChildren(div, this.parentNode, this);
+   }
},
removeAttr: function(name) {
this.removeAttribute(name);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78a534787bececb4677b12a5b8fe5b193b42809f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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