BUGFIX #70: Updated 'CSS selector' operation to use vanilla JS instead of jQuery, also fixing root element selection issues.

This commit is contained in:
n1474335 2017-02-07 15:04:10 +00:00
parent 553d9945ce
commit 35d74980a1
6 changed files with 27 additions and 21 deletions

View file

@ -378,24 +378,30 @@ var Code = {
* CSS selector operation.
*
* @author Mikescher (https://github.com/Mikescher | https://mikescher.com)
* @author n1474335 [n1474335@gmail.com]
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runCssQuery: function(input, args) {
runCSSQuery: function(input, args) {
var query = args[0],
delimiter = args[1];
delimiter = args[1],
parser = new DOMParser(),
html,
result;
if (!query.length || !input.length) {
return "";
}
var html;
try {
html = $.parseHTML(input);
html = parser.parseFromString(input, "text/html");
} catch (err) {
return "Invalid input HTML.";
}
var result;
try {
result = $(html).find(query);
result = html.querySelectorAll(query);
} catch (err) {
return "Invalid CSS Selector. Details:\n" + err.message;
}