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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1987,7 +1987,7 @@ var OperationConfig = {
},
"CSS selector": {
description: "Extract information from an HTML document with a CSS selector",
run: Code.runCssQuery,
run: Code.runCSSQuery,
inputType: "string",
outputType: "string",
args: [

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;
}

View File

@ -1,9 +1,9 @@
212 source files
115054 lines
115060 lines
4.3M size
142 JavaScript source files
105894 lines
105900 lines
3.8M size
83 third party JavaScript source files
@ -11,7 +11,7 @@
3.0M size
59 first party JavaScript source files
19636 lines
19642 lines
740K size
3.4M uncompressed JavaScript size