jenkins-bot has submitted this change and it was merged.
Change subject: Provide a way to get at text/comment nodes in parserTest
changes.
......................................................................
Provide a way to get at text/comment nodes in parserTest changes.
Change-Id: Iae8b68d0af1bdd1130cd5f9fd5453448bdb86769
---
M tests/parserTests.js
1 file changed, 16 insertions(+), 2 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/parserTests.js b/tests/parserTests.js
index ec2546d..6e61b8a 100755
--- a/tests/parserTests.js
+++ b/tests/parserTests.js
@@ -792,6 +792,9 @@
// that is, ['fig', 'attr', 'width', '120'] is interpreted as
// $('fig').attr('width', '120')
// See http://api.jquery.com/ for documentation of these methods.
+ // "contents" as second argument calls the jquery .contents() method
+ // on the results of the selector in the first argument, which is
+ // a good way to get at the text and comment nodes
var jquery = {
attr: function(name, val) {
this.setAttribute(name, val);
@@ -811,8 +814,12 @@
remove: function(optSelector) {
// jquery lets us specify an optional selector to
further
// restrict the removed elements.
- var what = optSelector ?
- this.querySelectorAll(optSelector) : [ this ];
+ // text nodes don't have the "querySelectorAll" method,
so
+ // just include them by default (jquery excludes them,
which
+ // is less useful)
+ var what = !optSelector ? [ this ] :
+ !DU.isElt(this) ? [ this ] /* text node hack!
*/ :
+ this.querySelectorAll(optSelector);
Array.prototype.forEach.call(what, function(node) {
if (node.parentNode) {
node.parentNode.removeChild(node); }
});
@@ -837,6 +844,13 @@
document.outerHTML);
return;
}
+ if (change[1] === 'contents') {
+ change.shift();
+ els = Array.prototype.reduce.call(els, function(acc,
el) {
+ acc.push.apply(acc, el.childNodes);
+ return acc;
+ }, []);
+ }
var fun = jquery[change[1]];
if (!fun) {
err = new Error('bad mutator function: '+change[1]);
--
To view, visit https://gerrit.wikimedia.org/r/179509
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iae8b68d0af1bdd1130cd5f9fd5453448bdb86769
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Marcoil <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits