Skip to content

Commit c15a644

Browse files
committed
Refactor code-style
1 parent ebc49d0 commit c15a644

File tree

2 files changed

+175
-183
lines changed

2 files changed

+175
-183
lines changed

lib/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,29 @@
44
*
55
* @typedef {import('hast').Element} HastElement
66
* @typedef {import('hast').Properties} HastProperties
7-
*
8-
* @typedef {'html' | 'svg'} Space
9-
* Name of namespace.
10-
*
7+
*/
8+
9+
/**
1110
* @typedef Options
1211
* Configuration.
1312
* @property {Space} [space]
14-
* Which space first element in the selector is in.
13+
* Which space first element in the selector is in (default: `'html'`).
1514
*
1615
* When an `svg` element is created in HTML, the space is automatically
1716
* switched to SVG.
1817
*
18+
* @typedef {'html' | 'svg'} Space
19+
* Name of namespace.
20+
*
1921
* @typedef State
2022
* Info on current context.
2123
* @property {Space} space
2224
* Current space.
2325
*/
2426

27+
import {createParser} from 'css-selector-parser'
2528
import {ok as assert} from 'devlop'
2629
import {h, s} from 'hastscript'
27-
import {createParser} from 'css-selector-parser'
2830

2931
const cssSelectorParse = createParser({syntax: 'selectors-4'})
3032

@@ -33,18 +35,18 @@ const cssSelectorParse = createParser({syntax: 'selectors-4'})
3335
* Create one or more `Element`s from a CSS selector.
3436
*
3537
* @param {string | null | undefined} [selector='']
36-
* CSS selector.
37-
* @param {Space | Options | null | undefined} [space='html']
38-
* Space or configuration.
38+
* CSS selector (default: `''`).
39+
* @param {Options | Space | null | undefined} [options]
40+
* Configuration (optional).
3941
* @returns {HastElement}
4042
* Built tree.
4143
*/
42-
export function fromSelector(selector, space) {
44+
export function fromSelector(selector, options) {
4345
/** @type {State} */
4446
const state = {
4547
space:
46-
(space && typeof space === 'object' && space.space) ||
47-
(typeof space === 'string' && space) ||
48+
(options && typeof options === 'object' && options.space) ||
49+
(typeof options === 'string' && options) ||
4850
'html'
4951
}
5052

0 commit comments

Comments
 (0)