Skip to content

Commit 3a1087b

Browse files
committed
Refactor comments
1 parent a9ba77f commit 3a1087b

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

lib/any.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function collector(one) {
110110

111111
return collect
112112

113-
/* Append elements to array, filtering out duplicates. */
113+
// Append elements to array, filtering out duplicates.
114114
function collect(source) {
115115
if ('length' in source) {
116116
collectAll()

lib/attribute.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ function match(query, node, schema) {
3939
return true
4040
}
4141

42-
/* [attr] */
42+
// `[attr]`
4343
function exists(query, node, info) {
4444
return has(node, info.property)
4545
}
4646

47-
/* [attr=value] */
47+
// `[attr=value]`
4848
function exact(query, node, info) {
4949
if (!has(node, info.property)) {
5050
return false
@@ -53,7 +53,7 @@ function exact(query, node, info) {
5353
return normalizeValue(node.properties[info.property], info) === query.value
5454
}
5555

56-
/* [attr~=value] */
56+
// `[attr~=value]`
5757
function spaceSeparatedList(query, node, info) {
5858
var val
5959

@@ -63,8 +63,8 @@ function spaceSeparatedList(query, node, info) {
6363

6464
val = node.properties[info.property]
6565

66-
/* If this is a comma-separated list, and the query is contained in it,
67-
* return true. */
66+
// If this is a comma-separated list, and the query is contained in it, return
67+
// true.
6868
if (
6969
typeof val === 'object' &&
7070
!info.commaSeparated &&
@@ -73,12 +73,12 @@ function spaceSeparatedList(query, node, info) {
7373
return true
7474
}
7575

76-
/* For all other values (including comma-separated lists),
77-
* return whether this is an exact match. */
76+
// For all other values (including comma-separated lists), return whether this
77+
// is an exact match.
7878
return normalizeValue(val, info) === query.value
7979
}
8080

81-
/* [attr|=value] */
81+
// `[attr|=value]`
8282
function exactOrPrefix(query, node, info) {
8383
var value
8484

@@ -95,7 +95,7 @@ function exactOrPrefix(query, node, info) {
9595
)
9696
}
9797

98-
/* [attr^=value] */
98+
// `[attr^=value]`
9999
function begins(query, node, info) {
100100
var value
101101

@@ -108,7 +108,7 @@ function begins(query, node, info) {
108108
return value.slice(0, query.value.length) === query.value
109109
}
110110

111-
/* [attr$=value] */
111+
// `[attr$=value]`
112112
function ends(query, node, info) {
113113
if (!has(node, info.property)) {
114114
return false
@@ -121,7 +121,7 @@ function ends(query, node, info) {
121121
)
122122
}
123123

124-
/* [attr*=value] */
124+
// `[attr*=value]`
125125
function contains(query, node, info) {
126126
if (!has(node, info.property)) {
127127
return false
@@ -139,7 +139,7 @@ function unknownOperator(query) {
139139
throw new Error('Unknown operator `' + query.operator + '`')
140140
}
141141

142-
/* Stringify a hast value back to its HTML form. */
142+
// Stringify a hast value back to its HTML form.
143143
function normalizeValue(value, info) {
144144
if (typeof value === 'number') {
145145
value = String(value)

lib/enter-state.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,29 @@ function enter(state, node) {
5757
found = true
5858
}
5959

60-
// See: https://html.spec.whatwg.org/#the-directionality
61-
// Explicit `[dir=rtl]`
60+
// See: <https://html.spec.whatwg.org/#the-directionality>.
61+
// Explicit `[dir=rtl]`.
6262
if (dir === rtl) {
6363
dirInferred = dir
6464
} else if (
65-
// Explicit `[dir=ltr]`
65+
// Explicit `[dir=ltr]`.
6666
dir === ltr ||
67-
// HTML with an invalid or no `[dir]`
67+
// HTML with an invalid or no `[dir]`.
6868
(dir !== auto && is(node, 'html')) ||
69-
// `input[type=tel]` with an invalid or no `[dir]`
69+
// `input[type=tel]` with an invalid or no `[dir]`.
7070
(dir !== auto && is(node, 'input') && props.type === 'tel')
7171
) {
7272
dirInferred = ltr
73-
// `[dir=auto]` or `bdi` with an invalid or no `[dir]`
73+
// `[dir=auto]` or `bdi` with an invalid or no `[dir]`.
7474
} else if (dir === auto || is(node, 'bdi')) {
7575
if (is(node, 'textarea')) {
76-
// Check contents of textarea
76+
// Check contents of `<textarea>`.
7777
dirInferred = dirBidi(toString(node))
7878
} else if (is(node, 'input') && valueTypes.indexOf(type) !== -1) {
79-
// Check value of input
79+
// Check value of `<input>`.
8080
dirInferred = props.value ? dirBidi(props.value) : ltr
8181
} else {
82-
// Check text nodes in `node`
82+
// Check text nodes in `node`.
8383
visit(node, inferDirectionality)
8484
}
8585
}

lib/nest.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ var handle = zwitch('nestingOperator')
1212
var handlers = handle.handlers
1313

1414
handle.unknown = unknownNesting
15-
handle.invalid = topScan /* `undefined` is the top query selector. */
16-
handlers.null = descendant /* `null` is the descendant combinator. */
15+
handle.invalid = topScan // `undefined` is the top query selector.
16+
handlers.null = descendant // `null` is the descendant combinator.
1717
handlers['>'] = child
1818
handlers['+'] = adjacentSibling
1919
handlers['~'] = generalSibling
@@ -95,7 +95,7 @@ function generalSibling(query, node, index, parent, state) {
9595
.done()
9696
}
9797

98-
/* Handles typeIndex and typeCount properties for every walker. */
98+
// Handles `typeIndex` and `typeCount` properties for every walker.
9999
function walkIterator(query, parent, state) {
100100
var nodes = parent.children
101101
var typeIndex = state.index ? createTypeIndex() : null
@@ -150,7 +150,7 @@ function walkIterator(query, parent, state) {
150150
pushNode()
151151
}
152152

153-
/* Stop if we’re looking for one node and it’s already found. */
153+
// Stop if we’re looking for one node and it’s already found.
154154
if (state.one && state.found) {
155155
return this
156156
}
@@ -210,7 +210,7 @@ function createTypeIndex() {
210210
counts[type] = 0
211211
}
212212

213-
/* Note: ++ needs is intended to be postfixed! */
213+
// Note: ++ needs is intended to be postfixed!
214214
return counts[type]++
215215
}
216216

test/matches.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,10 @@ test('select.matches()', function(t) {
858858
sst.ok(matches('a:has(img )', h('a', h('img'))), 'assertion (#3)')
859859
sst.ok(matches('a:has( img ,\t p )', h('a', h('img'))), 'assertion (#4)')
860860

861-
// Sst.ok(
861+
// Note: These should be unquoted, but that’s not supported by the CSS
862+
// parser:
863+
//
864+
// sst.ok(
862865
// matches('a:has(> img)', h('a', h('img'))),
863866
// 'true for relative direct child selector'
864867
// )
@@ -871,8 +874,6 @@ test('select.matches()', function(t) {
871874
// 'should support a list of relative selectors'
872875
// )
873876

874-
// Note: These should be unquoted, but that’s not supported by the CSS parser.
875-
876877
sst.end()
877878
})
878879

@@ -1092,6 +1093,7 @@ test('select.matches()', function(t) {
10921093
)
10931094

10941095
// Not supported by `css-selector-parser` yet :(
1096+
//
10951097
// sst.ok(
10961098
// matches(':lang("fr-BE", "de-*-DE")', h('html', {lang: 'de-Latn-DE'})),
10971099
// 'should support non-primary wildcard subtags (#2)'

0 commit comments

Comments
 (0)