mirror of
https://github.com/openharmony/third_party_css-what.git
synced 2026-07-01 03:23:11 -04:00
update OpenHarmony 2.0 Canary
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"Name": "css-what",
|
||||
"License": "BSD 2-Clause License",
|
||||
"License File": "LICENSE",
|
||||
"Version Number": "2.1.3",
|
||||
"Owner": "lixingchi1@huawei.com",
|
||||
"Upstream URL": "https://github.com/fb55/css-what",
|
||||
"Description": "a CSS selector parser."
|
||||
}
|
||||
]
|
||||
@@ -1,36 +0,0 @@
|
||||
# third_party_css-what
|
||||
|
||||
#### Description
|
||||
Third-party open-source software css-what | 三方开源软件css-what
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
#### Installation
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### Contribution
|
||||
|
||||
1. Fork the repository
|
||||
2. Create Feat_xxx branch
|
||||
3. Commit your code
|
||||
4. Create Pull Request
|
||||
|
||||
|
||||
#### Gitee Feature
|
||||
|
||||
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
||||
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
||||
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
||||
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
||||
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -1,37 +0,0 @@
|
||||
# third_party_css-what
|
||||
|
||||
#### 介绍
|
||||
Third-party open-source software css-what | 三方开源软件css-what
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
@@ -0,0 +1,274 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = parse;
|
||||
|
||||
var re_name = /^(?:\\.|[\w\-\u00b0-\uFFFF])+/,
|
||||
re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig,
|
||||
//modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
|
||||
re_attr = /^\s*((?:\\.|[\w\u00b0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF\-])*)|)|)\s*(i)?\]/;
|
||||
|
||||
var actionTypes = {
|
||||
__proto__: null,
|
||||
"undefined": "exists",
|
||||
"": "equals",
|
||||
"~": "element",
|
||||
"^": "start",
|
||||
"$": "end",
|
||||
"*": "any",
|
||||
"!": "not",
|
||||
"|": "hyphen"
|
||||
};
|
||||
|
||||
var simpleSelectors = {
|
||||
__proto__: null,
|
||||
">": "child",
|
||||
"<": "parent",
|
||||
"~": "sibling",
|
||||
"+": "adjacent"
|
||||
};
|
||||
|
||||
var attribSelectors = {
|
||||
__proto__: null,
|
||||
"#": ["id", "equals"],
|
||||
".": ["class", "element"]
|
||||
};
|
||||
|
||||
//pseudos, whose data-property is parsed as well
|
||||
var unpackPseudos = {
|
||||
__proto__: null,
|
||||
"has": true,
|
||||
"not": true,
|
||||
"matches": true
|
||||
};
|
||||
|
||||
var stripQuotesFromPseudos = {
|
||||
__proto__: null,
|
||||
"contains": true,
|
||||
"icontains": true
|
||||
};
|
||||
|
||||
var quotes = {
|
||||
__proto__: null,
|
||||
"\"": true,
|
||||
"'": true
|
||||
};
|
||||
|
||||
//unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L139
|
||||
function funescape( _, escaped, escapedWhitespace ) {
|
||||
var high = "0x" + escaped - 0x10000;
|
||||
// NaN means non-codepoint
|
||||
// Support: Firefox
|
||||
// Workaround erroneous numeric interpretation of +"0x"
|
||||
return high !== high || escapedWhitespace ?
|
||||
escaped :
|
||||
// BMP codepoint
|
||||
high < 0 ?
|
||||
String.fromCharCode( high + 0x10000 ) :
|
||||
// Supplemental Plane codepoint (surrogate pair)
|
||||
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
|
||||
}
|
||||
|
||||
function unescapeCSS(str){
|
||||
return str.replace(re_escape, funescape);
|
||||
}
|
||||
|
||||
function isWhitespace(c){
|
||||
return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
|
||||
}
|
||||
|
||||
function parse(selector, options){
|
||||
var subselects = [];
|
||||
|
||||
selector = parseSelector(subselects, selector + "", options);
|
||||
|
||||
if(selector !== ""){
|
||||
throw new SyntaxError("Unmatched selector: " + selector);
|
||||
}
|
||||
|
||||
return subselects;
|
||||
}
|
||||
|
||||
function parseSelector(subselects, selector, options){
|
||||
var tokens = [],
|
||||
sawWS = false,
|
||||
data, firstChar, name, quot;
|
||||
|
||||
function getName(){
|
||||
var sub = selector.match(re_name)[0];
|
||||
selector = selector.substr(sub.length);
|
||||
return unescapeCSS(sub);
|
||||
}
|
||||
|
||||
function stripWhitespace(start){
|
||||
while(isWhitespace(selector.charAt(start))) start++;
|
||||
selector = selector.substr(start);
|
||||
}
|
||||
|
||||
function isEscaped(pos) {
|
||||
var slashCount = 0;
|
||||
|
||||
while (selector.charAt(--pos) === "\\") slashCount++;
|
||||
return (slashCount & 1) === 1;
|
||||
}
|
||||
|
||||
stripWhitespace(0);
|
||||
|
||||
while(selector !== ""){
|
||||
firstChar = selector.charAt(0);
|
||||
|
||||
if(isWhitespace(firstChar)){
|
||||
sawWS = true;
|
||||
stripWhitespace(1);
|
||||
} else if(firstChar in simpleSelectors){
|
||||
tokens.push({type: simpleSelectors[firstChar]});
|
||||
sawWS = false;
|
||||
|
||||
stripWhitespace(1);
|
||||
} else if(firstChar === ","){
|
||||
if(tokens.length === 0){
|
||||
throw new SyntaxError("empty sub-selector");
|
||||
}
|
||||
subselects.push(tokens);
|
||||
tokens = [];
|
||||
sawWS = false;
|
||||
stripWhitespace(1);
|
||||
} else {
|
||||
if(sawWS){
|
||||
if(tokens.length > 0){
|
||||
tokens.push({type: "descendant"});
|
||||
}
|
||||
sawWS = false;
|
||||
}
|
||||
|
||||
if(firstChar === "*"){
|
||||
selector = selector.substr(1);
|
||||
tokens.push({type: "universal"});
|
||||
} else if(firstChar in attribSelectors){
|
||||
selector = selector.substr(1);
|
||||
tokens.push({
|
||||
type: "attribute",
|
||||
name: attribSelectors[firstChar][0],
|
||||
action: attribSelectors[firstChar][1],
|
||||
value: getName(),
|
||||
ignoreCase: false
|
||||
});
|
||||
} else if(firstChar === "["){
|
||||
selector = selector.substr(1);
|
||||
data = selector.match(re_attr);
|
||||
if(!data){
|
||||
throw new SyntaxError("Malformed attribute selector: " + selector);
|
||||
}
|
||||
selector = selector.substr(data[0].length);
|
||||
name = unescapeCSS(data[1]);
|
||||
|
||||
if(
|
||||
!options || (
|
||||
"lowerCaseAttributeNames" in options ?
|
||||
options.lowerCaseAttributeNames :
|
||||
!options.xmlMode
|
||||
)
|
||||
){
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
tokens.push({
|
||||
type: "attribute",
|
||||
name: name,
|
||||
action: actionTypes[data[2]],
|
||||
value: unescapeCSS(data[4] || data[5] || ""),
|
||||
ignoreCase: !!data[6]
|
||||
});
|
||||
|
||||
} else if(firstChar === ":"){
|
||||
if(selector.charAt(1) === ":"){
|
||||
selector = selector.substr(2);
|
||||
tokens.push({type: "pseudo-element", name: getName().toLowerCase()});
|
||||
continue;
|
||||
}
|
||||
|
||||
selector = selector.substr(1);
|
||||
|
||||
name = getName().toLowerCase();
|
||||
data = null;
|
||||
|
||||
if(selector.charAt(0) === "("){
|
||||
if(name in unpackPseudos){
|
||||
quot = selector.charAt(1);
|
||||
var quoted = quot in quotes;
|
||||
|
||||
selector = selector.substr(quoted + 1);
|
||||
|
||||
data = [];
|
||||
selector = parseSelector(data, selector, options);
|
||||
|
||||
if(quoted){
|
||||
if(selector.charAt(0) !== quot){
|
||||
throw new SyntaxError("unmatched quotes in :" + name);
|
||||
} else {
|
||||
selector = selector.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(selector.charAt(0) !== ")"){
|
||||
throw new SyntaxError("missing closing parenthesis in :" + name + " " + selector);
|
||||
}
|
||||
|
||||
selector = selector.substr(1);
|
||||
} else {
|
||||
var pos = 1, counter = 1;
|
||||
|
||||
for(; counter > 0 && pos < selector.length; pos++){
|
||||
if(selector.charAt(pos) === "(" && !isEscaped(pos)) counter++;
|
||||
else if(selector.charAt(pos) === ")" && !isEscaped(pos)) counter--;
|
||||
}
|
||||
|
||||
if(counter){
|
||||
throw new SyntaxError("parenthesis not matched");
|
||||
}
|
||||
|
||||
data = selector.substr(1, pos - 2);
|
||||
selector = selector.substr(pos);
|
||||
|
||||
if(name in stripQuotesFromPseudos){
|
||||
quot = data.charAt(0);
|
||||
|
||||
if(quot === data.slice(-1) && quot in quotes){
|
||||
data = data.slice(1, -1);
|
||||
}
|
||||
|
||||
data = unescapeCSS(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tokens.push({type: "pseudo", name: name, data: data});
|
||||
} else if(re_name.test(selector)){
|
||||
name = getName();
|
||||
|
||||
if(!options || ("lowerCaseTags" in options ? options.lowerCaseTags : !options.xmlMode)){
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
tokens.push({type: "tag", name: name});
|
||||
} else {
|
||||
if(tokens.length && tokens[tokens.length - 1].type === "descendant"){
|
||||
tokens.pop();
|
||||
}
|
||||
addToken(subselects, tokens);
|
||||
return selector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addToken(subselects, tokens);
|
||||
|
||||
return selector;
|
||||
}
|
||||
|
||||
function addToken(subselects, tokens){
|
||||
if(subselects.length > 0 && tokens.length === 0){
|
||||
throw new SyntaxError("empty sub-selector");
|
||||
}
|
||||
|
||||
subselects.push(tokens);
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"_from": "css-what@^2.1.3",
|
||||
"_id": "css-what@2.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==",
|
||||
"_location": "/css-what",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "css-what@^2.1.3",
|
||||
"name": "css-what",
|
||||
"escapedName": "css-what",
|
||||
"rawSpec": "^2.1.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz",
|
||||
"_shasum": "a6d7604573365fe74686c3f311c56513d88285f2",
|
||||
"_spec": "css-what@^2.1.3",
|
||||
"_where": "/home/c00321158/hmf-ace-ohos/third_party/jsframework",
|
||||
"author": {
|
||||
"name": "Felix Böhm",
|
||||
"email": "me@feedic.com",
|
||||
"url": "http://feedic.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/fb55/css-what/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "a CSS selector parser",
|
||||
"devDependencies": {
|
||||
"jshint": "2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/fb55/css-what#readme",
|
||||
"jshintConfig": {
|
||||
"eqeqeq": true,
|
||||
"freeze": true,
|
||||
"latedef": "nofunc",
|
||||
"noarg": true,
|
||||
"nonbsp": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"eqnull": true,
|
||||
"proto": true,
|
||||
"node": true,
|
||||
"globals": {
|
||||
"describe": true,
|
||||
"it": true
|
||||
}
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "./index.js",
|
||||
"name": "css-what",
|
||||
"optionalDependencies": {},
|
||||
"prettier": {
|
||||
"tabWidth": 4
|
||||
},
|
||||
"repository": {
|
||||
"url": "git+https://github.com/fb55/css-what.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node tests/test.js && jshint *.js"
|
||||
},
|
||||
"version": "2.1.3"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
# css-what [](http://travis-ci.org/fb55/css-what)
|
||||
|
||||
a CSS selector parser
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
require('css-what')('foo[bar]:baz')
|
||||
|
||||
~> [ [ { type: 'tag', name: 'foo' },
|
||||
{ type: 'attribute',
|
||||
name: 'bar',
|
||||
action: 'exists',
|
||||
value: '',
|
||||
ignoreCase: false },
|
||||
{ type: 'pseudo',
|
||||
name: 'baz',
|
||||
data: null } ] ]
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
__`CSSwhat(selector, options)` - Parses `str`, with the passed `options`.__
|
||||
|
||||
The function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
|
||||
|
||||
name | attributes | example | output
|
||||
---- | ---------- | ------- | ------
|
||||
`tag`| `name` | `div` | `{ type: 'tag', name: 'div' }`
|
||||
`universal`| - | `*` | `{ type: 'universal' }`
|
||||
`pseudo`| `name`, `data`|`:name(data)`| `{ type: 'pseudo', name: 'name', data: 'data' }`
|
||||
`pseudo`| `name`, `data`|`:name`| `{ type: 'pseudo', name: 'name', data: null }`
|
||||
`pseudo-element`| `name` |`::name`| `{ type: 'pseudo-element', name: 'name' }`
|
||||
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr]`|`{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }`
|
||||
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr=val]`|`{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }`
|
||||
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr^=val]`|`{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }`
|
||||
`attribute`|`name`, `action`, `value`, `ignoreCase`|`[attr$=val]`|`{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }`
|
||||
`child`| - | `>` | `{ type: 'child' }`
|
||||
`parent`| - | `<` | `{ type: 'parent' }`
|
||||
`sibling`| - | `~` | `{ type: 'sibling' }`
|
||||
`adjacent`| - | `+` | `{ type: 'adjacent' }`
|
||||
`descendant`| - | | `{ type: 'descendant' }`
|
||||
|
||||
|
||||
__Options:__
|
||||
|
||||
- `xmlMode`: When enabled, tag names will be case-sensitive (meaning they won't be lowercased).
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
Reference in New Issue
Block a user