Files
pjax/tests/lib/foreach-selectors.js

41 lines
897 B
JavaScript
Raw Normal View History

2019-03-03 01:37:45 -05:00
var tape = require("tape");
2014-05-23 06:54:20 +02:00
2019-03-03 01:37:45 -05:00
var forEachEls = require("../../lib/foreach-selectors.js");
2014-05-23 06:54:20 +02:00
var cb = function(el) {
2019-03-03 01:37:45 -05:00
el.className = "modified";
};
2014-05-23 06:54:20 +02:00
tape("test forEachSelector", function(t) {
2019-03-03 01:37:45 -05:00
forEachEls(["html", "body"], cb);
t.equal(
document.documentElement.className,
"modified",
"callback has been executed on first selector"
);
t.equal(
document.body.className,
"modified",
"callback has been executed on first selector"
);
document.documentElement.className = "";
document.body.className = "";
forEachEls(["html", "body"], cb, null, document.documentElement);
t.equal(
document.documentElement.className,
"",
"callback has not been executed on first selector when context is used"
);
t.equal(
document.body.className,
"modified",
"callback has been executed on first selector when context is used"
);
t.end();
});