File tree Expand file tree Collapse file tree 4 files changed +50
-3
lines changed
Expand file tree Collapse file tree 4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11.DS_Store
2+ * .d.ts
23* .log
34coverage /
45node_modules /
Original file line number Diff line number Diff line change 1+ /**
2+ * @typedef {import('hast').Properties } Properties
3+ * @typedef {import('hast').Element } Element
4+ */
5+
16var search = / [ # . ] / g
27
3- // Create a hast element from a simple CSS selector.
8+ /**
9+ * Create a hast element from a simple CSS selector.
10+ *
11+ * @param {string } [selector]
12+ * @param {string } [name='div']
13+ * @returns {Element }
14+ */
415export function parseSelector ( selector , name = 'div' ) {
516 var value = selector || ''
17+ /** @type {Properties } */
618 var props = { }
719 var start = 0
20+ /** @type {string } */
821 var subvalue
22+ /** @type {string } */
923 var previous
24+ /** @type {RegExpMatchArray } */
1025 var match
1126
1227 while ( start < value . length ) {
@@ -19,7 +34,7 @@ export function parseSelector(selector, name = 'div') {
1934 name = subvalue
2035 } else if ( previous === '#' ) {
2136 props . id = subvalue
22- } else if ( props . className ) {
37+ } else if ( Array . isArray ( props . className ) ) {
2338 props . className . push ( subvalue )
2439 } else {
2540 props . className = [ subvalue ]
Original file line number Diff line number Diff line change 2727 "sideEffects" : false ,
2828 "type" : " module" ,
2929 "main" : " index.js" ,
30+ "types" : " index.d.ts" ,
3031 "files" : [
32+ " index.d.ts" ,
3133 " index.js"
3234 ],
35+ "dependencies" : {
36+ "@types/hast" : " ^2.0.0"
37+ },
3338 "devDependencies" : {
39+ "@types/tape" : " ^4.0.0" ,
3440 "c8" : " ^7.0.0" ,
3541 "prettier" : " ^2.0.0" ,
3642 "remark-cli" : " ^9.0.0" ,
3743 "remark-preset-wooorm" : " ^8.0.0" ,
44+ "rimraf" : " ^3.0.0" ,
3845 "tape" : " ^5.0.0" ,
46+ "type-coverage" : " ^2.0.0" ,
47+ "typescript" : " ^4.0.0" ,
3948 "xo" : " ^0.39.0"
4049 },
4150 "scripts" : {
51+ "prepack" : " npm run build && npm run format" ,
52+ "build" : " rimraf \" *.d.ts\" && tsc && type-coverage" ,
4253 "format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
4354 "test-api" : " node test.js" ,
4455 "test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js" ,
45- "test" : " npm run format && npm run test-coverage"
56+ "test" : " npm run build && npm run format && npm run test-coverage"
4657 },
4758 "prettier" : {
4859 "tabWidth" : 2 ,
6374 "plugins" : [
6475 " preset-wooorm"
6576 ]
77+ },
78+ "typeCoverage" : {
79+ "atLeast" : 100 ,
80+ "detail" : true ,
81+ "strict" : true
6682 }
6783}
Original file line number Diff line number Diff line change 1+ {
2+ "include" : [" *.js" ],
3+ "compilerOptions" : {
4+ "target" : " ES2020" ,
5+ "lib" : [" ES2020" ],
6+ "module" : " ES2020" ,
7+ "moduleResolution" : " node" ,
8+ "allowJs" : true ,
9+ "checkJs" : true ,
10+ "declaration" : true ,
11+ "emitDeclarationOnly" : true ,
12+ "allowSyntheticDefaultImports" : true ,
13+ "skipLibCheck" : true
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments