node-html-parser 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/matcher.js +2 -15
- package/dist/main.js +2 -15
- package/dist/matcher.js +2 -15
- package/package.json +1 -1
package/dist/esm/matcher.js
CHANGED
|
@@ -161,31 +161,18 @@ export default class Matcher {
|
|
|
161
161
|
let attr_key = '';
|
|
162
162
|
let value = '';
|
|
163
163
|
if (tagName && tagName !== '*') {
|
|
164
|
-
let reg;
|
|
165
164
|
if (tagName.startsWith('#')) {
|
|
166
165
|
// source += 'if (el.id != ' + JSON.stringify(tagName.substr(1)) + ') return false;';// 1
|
|
167
166
|
function_name += '1';
|
|
168
167
|
}
|
|
169
168
|
else {
|
|
170
|
-
reg =
|
|
169
|
+
const reg = /\[\s*([\w-]+)(\s*=\s*(((?<quote>'|")\s*(.*)(\k<quote>))|(\S*)))?\s*\]/.exec(tagName);
|
|
171
170
|
if (reg) {
|
|
172
171
|
attr_key = reg[1];
|
|
173
|
-
|
|
174
|
-
if (method !== '=' && method !== '!=') {
|
|
175
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
176
|
-
throw new Error('Selector not supported, Expect [key${op}value].op must be =,!=');
|
|
177
|
-
}
|
|
178
|
-
if (method === '=') {
|
|
179
|
-
method = '==';
|
|
180
|
-
}
|
|
181
|
-
value = reg[7] || reg[8];
|
|
172
|
+
value = reg[6] || reg[8];
|
|
182
173
|
// source += `let attrs = el.attributes;for (let key in attrs){const val = attrs[key]; if (key == "${attr_key}" && val == "${value}"){return true;}} return false;`;// 2
|
|
183
174
|
function_name += '2';
|
|
184
175
|
}
|
|
185
|
-
else if ((reg = /^\[(.*?)\]/.exec(tagName))) {
|
|
186
|
-
attr_key = reg[1];
|
|
187
|
-
function_name += '5';
|
|
188
|
-
}
|
|
189
176
|
else {
|
|
190
177
|
// source += 'if (el.tagName != ' + JSON.stringify(tagName) + ') return false;';// 3
|
|
191
178
|
function_name += '3';
|
package/dist/main.js
CHANGED
|
@@ -312,31 +312,18 @@ define("matcher", ["require", "exports"], function (require, exports) {
|
|
|
312
312
|
var attr_key = '';
|
|
313
313
|
var value = '';
|
|
314
314
|
if (tagName && tagName !== '*') {
|
|
315
|
-
var reg = void 0;
|
|
316
315
|
if (tagName.startsWith('#')) {
|
|
317
316
|
// source += 'if (el.id != ' + JSON.stringify(tagName.substr(1)) + ') return false;';// 1
|
|
318
317
|
function_name += '1';
|
|
319
318
|
}
|
|
320
319
|
else {
|
|
321
|
-
reg =
|
|
320
|
+
var reg = /\[\s*([\w-]+)(\s*=\s*(((?<quote>'|")\s*(.*)(\k<quote>))|(\S*)))?\s*\]/.exec(tagName);
|
|
322
321
|
if (reg) {
|
|
323
322
|
attr_key = reg[1];
|
|
324
|
-
|
|
325
|
-
if (method !== '=' && method !== '!=') {
|
|
326
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
327
|
-
throw new Error('Selector not supported, Expect [key${op}value].op must be =,!=');
|
|
328
|
-
}
|
|
329
|
-
if (method === '=') {
|
|
330
|
-
method = '==';
|
|
331
|
-
}
|
|
332
|
-
value = reg[7] || reg[8];
|
|
323
|
+
value = reg[6] || reg[8];
|
|
333
324
|
// source += `let attrs = el.attributes;for (let key in attrs){const val = attrs[key]; if (key == "${attr_key}" && val == "${value}"){return true;}} return false;`;// 2
|
|
334
325
|
function_name += '2';
|
|
335
326
|
}
|
|
336
|
-
else if ((reg = /^\[(.*?)\]/.exec(tagName))) {
|
|
337
|
-
attr_key = reg[1];
|
|
338
|
-
function_name += '5';
|
|
339
|
-
}
|
|
340
327
|
else {
|
|
341
328
|
// source += 'if (el.tagName != ' + JSON.stringify(tagName) + ') return false;';// 3
|
|
342
329
|
function_name += '3';
|
package/dist/matcher.js
CHANGED
|
@@ -163,31 +163,18 @@ var Matcher = /** @class */ (function () {
|
|
|
163
163
|
var attr_key = '';
|
|
164
164
|
var value = '';
|
|
165
165
|
if (tagName && tagName !== '*') {
|
|
166
|
-
var reg = void 0;
|
|
167
166
|
if (tagName.startsWith('#')) {
|
|
168
167
|
// source += 'if (el.id != ' + JSON.stringify(tagName.substr(1)) + ') return false;';// 1
|
|
169
168
|
function_name += '1';
|
|
170
169
|
}
|
|
171
170
|
else {
|
|
172
|
-
reg =
|
|
171
|
+
var reg = /\[\s*([\w-]+)(\s*=\s*(((?<quote>'|")\s*(.*)(\k<quote>))|(\S*)))?\s*\]/.exec(tagName);
|
|
173
172
|
if (reg) {
|
|
174
173
|
attr_key = reg[1];
|
|
175
|
-
|
|
176
|
-
if (method !== '=' && method !== '!=') {
|
|
177
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
178
|
-
throw new Error('Selector not supported, Expect [key${op}value].op must be =,!=');
|
|
179
|
-
}
|
|
180
|
-
if (method === '=') {
|
|
181
|
-
method = '==';
|
|
182
|
-
}
|
|
183
|
-
value = reg[7] || reg[8];
|
|
174
|
+
value = reg[6] || reg[8];
|
|
184
175
|
// source += `let attrs = el.attributes;for (let key in attrs){const val = attrs[key]; if (key == "${attr_key}" && val == "${value}"){return true;}} return false;`;// 2
|
|
185
176
|
function_name += '2';
|
|
186
177
|
}
|
|
187
|
-
else if ((reg = /^\[(.*?)\]/.exec(tagName))) {
|
|
188
|
-
attr_key = reg[1];
|
|
189
|
-
function_name += '5';
|
|
190
|
-
}
|
|
191
178
|
else {
|
|
192
179
|
// source += 'if (el.tagName != ' + JSON.stringify(tagName) + ') return false;';// 3
|
|
193
180
|
function_name += '3';
|
package/package.json
CHANGED