Skip to content

Commit

Permalink
Merge pull request #49 in EXTENSIONS/extended-css from fix/AG-2141 to…
Browse files Browse the repository at this point in the history
… master

* commit '5ca11353920f9fe9136539294274c704f1bb5f94':
  update builds
  • Loading branch information
slavaleleka committed May 20, 2020
2 parents c10702a + 5ca1135 commit d27f167
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 71 deletions.
51 changes: 17 additions & 34 deletions dist/extended-css.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! extended-css - v1.2.7 - Wed May 13 2020
/*! extended-css - v1.2.8 - Wed May 20 2020
* https://github.com/AdguardTeam/ExtendedCss
* Copyright (c) 2020 AdGuard ; Licensed LGPL-3.0
*/
Expand Down Expand Up @@ -3102,7 +3102,7 @@ var ExtendedSelectorFactory = function () {
Sizzle.selectors.pseudos['nth-ancestor'] = Sizzle.selectors.createPseudo(function (selector) {
var deep = Number(selector);

if (Number.isNaN(deep) || deep <= 0 || deep >= 256) {
if (Number.isNaN(deep) || deep < 1 || deep >= 256) {
throw new Error("Invalid argument of :nth-ancestor pseudo class: ".concat(selector));
}

Expand All @@ -3113,7 +3113,7 @@ var ExtendedSelectorFactory = function () {
Sizzle.selectors.pseudos['upward'] = Sizzle.selectors.createPseudo(function (input) {
if (input === '') {
throw new Error("Invalid argument of :upward pseudo class: ".concat(input));
} else if (Number.isInteger(input) && (input <= 0 || input >= 256)) {
} else if (Number.isInteger(input) && (input < 1 || input >= 256)) {
throw new Error("Invalid argument of :upward pseudo class: ".concat(input));
}

Expand Down Expand Up @@ -3192,6 +3192,7 @@ var ExtendedSelectorFactory = function () {
this.debug = true;
}
}

ExtendedSelectorParser.prototype = {
/**
* The main method, creates a selector instance depending on the type of a selector.
Expand All @@ -3217,24 +3218,18 @@ var ExtendedSelectorFactory = function () {

if (typeof upwardPart !== 'undefined') {
var output;
var upwardInput = parseInt(upwardPart, 10); // if upward input is not a number, we consider it is a selector
var upwardDeep = parseInt(upwardPart, 10); // if upward parameter is not a number, we consider it as a selector

if (upwardInput) {
var xpath = this.convertNthAncestorToken(upwardInput);
output = new XpathSelector(selectorText, xpath, debug);
} else {
if (Number.isNaN(upwardDeep)) {
output = new UpwardSelector(selectorText, upwardPart, debug);
} else {
// upward works like nth-ancestor
var xpath = this.convertNthAncestorToken(upwardDeep);
output = new XpathSelector(selectorText, xpath, debug);
}
} // if (typeof upwardPart !== 'undefined') {
// let output;
// if (upwardPart.type === XPATH_TYPE) {
// output = new XpathSelector(selectorText, upwardPart.value, debug);
// } else {
// output = new UpwardSelector(selectorText, upwardPart.value, debug);
// }
// return output;
// }

return output;
}

tokens = tokens[0];
var l = tokens.length;
Expand Down Expand Up @@ -3365,10 +3360,8 @@ var ExtendedSelectorFactory = function () {

/**
* @private
* @return {Object|undefined} type and value of upward selector part:
* - if upward gets a number — converts it to xpath,
* - if upward gets a selector - returns the selector for further operation.
* returns undefined if the input does not contain upward tokens
* @return {string|undefined} upward parameter
* or undefined if the input does not contain upward tokens
*/
getUpwardPart: function getUpwardPart() {
var tokens = this.tokens[0];
Expand All @@ -3385,17 +3378,7 @@ var ExtendedSelectorFactory = function () {
throw new Error('Invalid pseudo: \':upward\' should be at the end of the selector');
}

return matches[1]; // let type;
// let value;
// const input = parseInt(matches[1], 10);
// if (input) {
// type = XPATH_TYPE;
// value = this.convertNthAncestorToken(matches[1]);
// } else {
// type = SELECTOR_TYPE;
// value = matches[1];
// }
// return { type, value };
return matches[1];
}
}
}
Expand Down Expand Up @@ -3461,7 +3444,7 @@ var ExtendedSelectorFactory = function () {
*
* @param {string} selectorText
* @param {string} xpath value
* @param {boolean=}debug
* @param {boolean=} debug
* @constructor
*/

Expand Down Expand Up @@ -3527,7 +3510,7 @@ var ExtendedSelectorFactory = function () {
*
* @param {string} selectorText
* @param {string} upwardSelector value
* @param {boolean=}debug
* @param {boolean=} debug
* @constructor
*/

Expand Down
51 changes: 17 additions & 34 deletions dist/extended-css.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! extended-css - v1.2.7 - Wed May 13 2020
/*! extended-css - v1.2.8 - Wed May 20 2020
* https://github.com/AdguardTeam/ExtendedCss
* Copyright (c) 2020 AdGuard ; Licensed LGPL-3.0
*/
Expand Down Expand Up @@ -3105,7 +3105,7 @@ var ExtendedCss = (function () {
Sizzle.selectors.pseudos['nth-ancestor'] = Sizzle.selectors.createPseudo(function (selector) {
var deep = Number(selector);

if (Number.isNaN(deep) || deep <= 0 || deep >= 256) {
if (Number.isNaN(deep) || deep < 1 || deep >= 256) {
throw new Error("Invalid argument of :nth-ancestor pseudo class: ".concat(selector));
}

Expand All @@ -3116,7 +3116,7 @@ var ExtendedCss = (function () {
Sizzle.selectors.pseudos['upward'] = Sizzle.selectors.createPseudo(function (input) {
if (input === '') {
throw new Error("Invalid argument of :upward pseudo class: ".concat(input));
} else if (Number.isInteger(input) && (input <= 0 || input >= 256)) {
} else if (Number.isInteger(input) && (input < 1 || input >= 256)) {
throw new Error("Invalid argument of :upward pseudo class: ".concat(input));
}

Expand Down Expand Up @@ -3195,6 +3195,7 @@ var ExtendedCss = (function () {
this.debug = true;
}
}

ExtendedSelectorParser.prototype = {
/**
* The main method, creates a selector instance depending on the type of a selector.
Expand All @@ -3220,24 +3221,18 @@ var ExtendedCss = (function () {

if (typeof upwardPart !== 'undefined') {
var output;
var upwardInput = parseInt(upwardPart, 10); // if upward input is not a number, we consider it is a selector
var upwardDeep = parseInt(upwardPart, 10); // if upward parameter is not a number, we consider it as a selector

if (upwardInput) {
var xpath = this.convertNthAncestorToken(upwardInput);
output = new XpathSelector(selectorText, xpath, debug);
} else {
if (Number.isNaN(upwardDeep)) {
output = new UpwardSelector(selectorText, upwardPart, debug);
} else {
// upward works like nth-ancestor
var xpath = this.convertNthAncestorToken(upwardDeep);
output = new XpathSelector(selectorText, xpath, debug);
}
} // if (typeof upwardPart !== 'undefined') {
// let output;
// if (upwardPart.type === XPATH_TYPE) {
// output = new XpathSelector(selectorText, upwardPart.value, debug);
// } else {
// output = new UpwardSelector(selectorText, upwardPart.value, debug);
// }
// return output;
// }

return output;
}

tokens = tokens[0];
var l = tokens.length;
Expand Down Expand Up @@ -3368,10 +3363,8 @@ var ExtendedCss = (function () {

/**
* @private
* @return {Object|undefined} type and value of upward selector part:
* - if upward gets a number — converts it to xpath,
* - if upward gets a selector - returns the selector for further operation.
* returns undefined if the input does not contain upward tokens
* @return {string|undefined} upward parameter
* or undefined if the input does not contain upward tokens
*/
getUpwardPart: function getUpwardPart() {
var tokens = this.tokens[0];
Expand All @@ -3388,17 +3381,7 @@ var ExtendedCss = (function () {
throw new Error('Invalid pseudo: \':upward\' should be at the end of the selector');
}

return matches[1]; // let type;
// let value;
// const input = parseInt(matches[1], 10);
// if (input) {
// type = XPATH_TYPE;
// value = this.convertNthAncestorToken(matches[1]);
// } else {
// type = SELECTOR_TYPE;
// value = matches[1];
// }
// return { type, value };
return matches[1];
}
}
}
Expand Down Expand Up @@ -3464,7 +3447,7 @@ var ExtendedCss = (function () {
*
* @param {string} selectorText
* @param {string} xpath value
* @param {boolean=}debug
* @param {boolean=} debug
* @constructor
*/

Expand Down Expand Up @@ -3530,7 +3513,7 @@ var ExtendedCss = (function () {
*
* @param {string} selectorText
* @param {string} upwardSelector value
* @param {boolean=}debug
* @param {boolean=} debug
* @constructor
*/

Expand Down
4 changes: 2 additions & 2 deletions dist/extended-css.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extended-css",
"version": "1.2.7",
"version": "1.2.8",
"description": "Module for applying CSS styles with extended selection properties.",
"main": "dist/extended-css.esm.js",
"types": "dist/extended-css.d.ts",
Expand Down

0 comments on commit d27f167

Please sign in to comment.