Comparing version 0.5.3 to 0.5.4
@@ -13,9 +13,9 @@ "use strict"; | ||
}, | ||
next: function next(hierarchy, selectorState, config, validateSelector, query, onError) { | ||
next: function next() { | ||
if (this.finished()) { | ||
return false; | ||
} | ||
return queue.shift()(hierarchy, selectorState, config, validateSelector, query, onError); | ||
return queue.shift().apply(undefined, arguments); | ||
} | ||
}; | ||
} |
@@ -41,5 +41,7 @@ 'use strict'; | ||
var windowScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; | ||
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _configuration.configure)(); | ||
var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _queryEngine2.default)(windowScope, config.queryEngine); | ||
var customConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var customQuery = arguments[2]; | ||
var config = (0, _configuration.configure)(customConfig); | ||
var query = customQuery || (0, _queryEngine2.default)(windowScope, config.queryEngine | ||
/** | ||
@@ -50,3 +52,3 @@ * Handle errors in accordance with what is specified in the configuration | ||
*/ | ||
function onError(ex, element) { | ||
);function onError(ex, element) { | ||
// handle error | ||
@@ -88,15 +90,13 @@ if (config.errorHandling === true) { | ||
// the stack is used to build a layer of selectors, each layer coresponding to a specific element in the heirarchy | ||
stack: [], | ||
// for each level we create a private stack of properties, so that we can then merge them | ||
// comfortably and allow all methods to see the level at which existing properties have been set | ||
stack: Array(hierarchy.length).fill().map(function () { | ||
return []; | ||
}), | ||
// follow the current specificity level of the selector - the higher the better | ||
specificity: 0 | ||
// for each level we create a private stack of properties, so that we can then merge them | ||
// comfortably and allow all methods to see the level at which existing properties have | ||
// been set | ||
};for (var index = 0; index < hierarchy.length; index += 1) { | ||
selectorState.stack[index] = []; | ||
} | ||
// cycle through the available parsing methods and while we still have yet to find the requested element's one-to-one selector | ||
// we keep calling the methods until we are either satisfied or run out of methods | ||
while (!parser.finished() && !selectorState.verified) { | ||
// cycle through the available parsing methods and while we still have yet to find the requested element's one-to-one selector | ||
// we keep calling the methods until we are either satisfied or run out of methods | ||
};while (!parser.finished() && !selectorState.verified) { | ||
try { | ||
@@ -103,0 +103,0 @@ selectorState = parser.next(hierarchy, selectorState, config, _validateSelector2.default, query, onError |
@@ -7,16 +7,9 @@ export default function Parser (parsingMethods) { | ||
}, | ||
next (hierarchy, selectorState, config, validateSelector, query, onError) { | ||
next (...args) { | ||
if (this.finished()) { | ||
return false | ||
} | ||
return queue.shift()( | ||
hierarchy, | ||
selectorState, | ||
config, | ||
validateSelector, | ||
query, | ||
onError | ||
) | ||
return queue.shift()(...args) | ||
} | ||
} | ||
} |
@@ -11,5 +11,7 @@ import initQueryEngine, { wrap } from './queryEngine' | ||
windowScope = window, | ||
config = configure(), | ||
query = initQueryEngine(windowScope, config.queryEngine) | ||
customConfig = {}, | ||
customQuery | ||
) { | ||
const config = configure(customConfig) | ||
const query = customQuery || initQueryEngine(windowScope, config.queryEngine) | ||
/** | ||
@@ -61,3 +63,5 @@ * Handle errors in accordance with what is specified in the configuration | ||
// the stack is used to build a layer of selectors, each layer coresponding to a specific element in the heirarchy | ||
stack: [], | ||
// for each level we create a private stack of properties, so that we can then merge them | ||
// comfortably and allow all methods to see the level at which existing properties have been set | ||
stack: Array(hierarchy.length).fill().map(() => []), | ||
// follow the current specificity level of the selector - the higher the better | ||
@@ -67,8 +71,2 @@ specificity: 0 | ||
// for each level we create a private stack of properties, so that we can then merge them | ||
// comfortably and allow all methods to see the level at which existing properties have | ||
// been set | ||
for (let index = 0; index < hierarchy.length; index += 1) { | ||
selectorState.stack[index] = [] | ||
} | ||
// cycle through the available parsing methods and while we still have yet to find the requested element's one-to-one selector | ||
@@ -75,0 +73,0 @@ // we keep calling the methods until we are either satisfied or run out of methods |
{ | ||
"name": "simmerjs", | ||
"description": "A pure Javascript reverse CSS selector engine which calculates a DOM element's unique CSS selector on the current page.", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"author": "Gidi Meir Morris", | ||
@@ -6,0 +6,0 @@ "main": "lib/simmer.js", |
8779137
1642