Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simulate behavior of the new "Selectors Level 4" :scope selector
<!DOCTYPE html>
<title>NWMatcher Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../../src/nwmatcher-noqsa.js"></script>
<div class="a">
<div class="a1"></div>
<div class="a2"></div>
var aNode = NW.Dom.first('.a', document)
var entriesUnscoped ='*', aNode, function(e) { NW.Dom.match(e, 'body div'); });
var entriesScoped ='body div', aNode);
if (entriesUnscoped.length !== 2) {
console.log('1. Invalid number of entries, should be 2, got ' + entriesUnscoped.length);
} else {
console.log('1. Passed!');
if (entriesScoped.length !== 0) {
console.log('2. Invalid number of entries, should be 0, got ' + entriesScoped.length);
} else {
console.log('2. Passed!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment