Skip to content

Commit 2763398

Browse files
committed
Minor things
1 parent 79b5dad commit 2763398

9 files changed

Lines changed: 22 additions & 23 deletions

File tree

lib/match/selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ function matchPseudoClassSelector(element, { name, value }, context) {
10131013
case 'nth-of-type':
10141014
return isAnBOfType(element, value)
10151015
case 'where':
1016-
return isMatching(element, value, context, /* ignoreSpecifity = */ true)
1016+
return isMatching(element, value, context)
10171017
default:
10181018
return false
10191019
}

lib/parse/parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ import {
4141
isSemicolon,
4242
isWhitespace,
4343
} from '../utils/value.js'
44-
import { isNode, type as nodeType } from '../utils/node.js'
4544
import Stream from './stream.js'
4645
import expandDeclaration from './shorthand.js'
46+
import { isNode } from '../utils/node.js'
4747
import root from '../rules/definitions.js'
4848
import { serializeIdentifier } from '../serialize.js'
4949
import shorthands from '../properties/shorthands.js'
50-
import tokenize from './tokenize.js'
5150
import { toLowerCase } from '../utils/string.js'
51+
import tokenize from './tokenize.js'
5252

5353
/**
5454
* @param {object[]} declarations

lib/parse/simplify.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
import * as substitutions from '../values/substitutions.js'
33
import { angle, dimension, list, map, number, percentage } from '../values/value.js'
4-
import { canonicalize, getCanonicalUnitFromType } from '../values/dimensions.js'
54
import { areEqual, clamp, isInfinite, isNegativeZero, round, sign, toDegrees, toRadians } from '../utils/math.js'
5+
import { canonicalize, getCanonicalUnitFromType } from '../values/dimensions.js'
66
import { getCalculationType, matchNumericType, types as numericTypes } from './types.js'
77
import { isCalculation, isCombinable, isList, isNumeric, isOmitted } from '../utils/value.js'
88

@@ -274,14 +274,14 @@ export function simplifyCalculation(node, resolutionType) {
274274
}
275275
const index = round('down', node.base * (multiplier + 1), 1)
276276
if (!isInfinite(index)) {
277-
const value = min.value + index * step.value
277+
const value = min.value + (index * step.value)
278278
if (index === multiplier && areEqual(value, max.value, epsilon)) {
279279
return max
280280
}
281281
return map(min, () => value)
282282
}
283283
}
284-
return map(min, () => min.value + node.base * (max.value - min.value))
284+
return map(min, () => min.value + (node.base * (max.value - min.value)))
285285
}
286286
case 'rem':
287287
return map(

lib/parse/stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class Stream {
6363
}
6464

6565
/**
66-
* @param {number|object|string} [n]
66+
* @param {*} [n]
6767
* @param {...*} args
6868
* @returns {*}
6969
*/
@@ -114,7 +114,7 @@ export default class Stream {
114114
}
115115

116116
/**
117-
* @param {...object|...string} items
117+
* @param {...*} items
118118
* @returns {string|object[]}
119119
*/
120120
consumeRunOf(...items) {

scripts/extract.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import * as webref from './webref.js'
2020
import { quote, tab } from '../lib/utils/string.js'
2121
import arbitrary from '../lib/parse/arbitrary.js'
2222
import contextSensitiveTypes from '../lib/values/context-sensitive.js'
23-
import { definitions as dimensions } from '../lib/values/dimensions.js'
2423
import { findRule } from '../lib/utils/definition.js'
2524
import forgiving from '../lib/values/forgiving.js'
2625
import fs from 'node:fs/promises'
@@ -198,7 +197,7 @@ const replaced = {
198197
// https://github.com/w3c/csswg-drafts/issues/13010
199198
'<event-trigger-event>': 'activate | click | interest | touch | dblclick | keypress(<string>)',
200199
// https://github.com/w3c/csswg-drafts/issues/10797
201-
'<input-position>': "<calc-sum>",
200+
'<input-position>': '<calc-sum>',
202201
'<progress-source>': "<calc-sum> | <'animation-timeline'>",
203202
// https://github.com/w3c/fxtf-drafts/issues/532
204203
'<mask-reference>': 'none | <image>',

test/dom.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export class Text extends CharacterData { nodeType = TEXT_NODE_TYPE }
250250
export class Document extends Node {
251251

252252
adoptedStyleSheets = []
253+
defaultView = globalThis
253254
fullscreenElement = null
254255
nodeType = DOCUMENT_NODE_TYPE
255256
pictureInPictureElement = null

test/match.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ describe('selector', () => {
757757
* <input type="color">
758758
* <input type="color" value>
759759
* <input type="image">
760-
* <input type="number"> <!-- value set to "1" by the user -->
760+
* <input type="number"> <!-- the user set `value` to "1" -->
761761
* <input type="radio" checked>
762762
* <input type="reset">
763763
* <input type="submit">
@@ -772,7 +772,7 @@ describe('selector', () => {
772772
* <!-- :blank -->
773773
* <input type="checkbox" disabled readonly>
774774
* <input type="checkbox" value="value">
775-
* <input type="number" value="1"> <!-- value set to "" by the user -->
775+
* <input type="number" value="1"> <!-- the user set `value` to "" -->
776776
* <input type="radio">
777777
* <select value="value"></select>
778778
* <select multiple>
@@ -981,17 +981,17 @@ describe('selector', () => {
981981
* <div type="checkbox" checked="true"></div>
982982
*
983983
* <!-- :unchecked -->
984-
* <input type="checkbox" checked="true"> <!-- unchecked by the user -->
985-
* <input type="radio" checked="true"> <!-- unchecked by the user -->
984+
* <input type="checkbox" checked="true"> <!-- the user unchecked the input -->
985+
* <input type="radio" checked="true"> <!-- the user unchecked the input -->
986986
* <select multiple>
987-
* <option selected></option> <!-- unselected by the user -->
987+
* <option selected></option> <!-- the user unselected the option -->
988988
* <option></option>
989989
* </select>
990990
*
991991
* <!-- :checked -->
992992
* <input type="checkbox" checked disabled readonly>
993-
* <input type="checkbox"> <!-- checked by the user -->
994-
* <input type="radio"> <!-- checked by the user -->
993+
* <input type="checkbox"> <!-- the user checked the input -->
994+
* <input type="radio"> <!-- the user checked the input -->
995995
* <select>
996996
* <option></option>
997997
* </select>
@@ -1860,8 +1860,8 @@ describe('selector', () => {
18601860
* <input type="week" value="2000-W02" max="2000-W01">
18611861
*
18621862
* <!-- :in-range -->
1863-
* <input type="date" min="2000-01-01" value="1999-12-31" max="2000-01-02"> <!-- value set to empty string by the user -->
1864-
* <input type="date" min="1999-12-31" max="2000-01-02"> <!-- value set to "2000-01-01" by the user -->
1863+
* <input type="date" min="2000-01-01" value="1999-12-31" max="2000-01-02"> <!-- the user set `value` to empty string -->
1864+
* <input type="date" min="1999-12-31" max="2000-01-02"> <!-- the user set `value` to "2000-01-01" -->
18651865
* <input type="date" min="2000-01-01" value="2000-01-01" max="2000-01-01">
18661866
* <input type="datetime-local" min="1999-12-31T00:00" value="2000-01-01T00:00" max="2000-01-01T00:01">
18671867
* <input type="month" min="1999-12" value="2000-01" max="2000-02">
@@ -3895,12 +3895,13 @@ describe('selector', () => {
38953895
selectors.forEach(selector => assert.match(selector, document._selected.get(selector), document))
38963896
})
38973897
// Resource
3898+
test.todo(':animated-image')
38983899
test(':buffering, :muted, :paused, :playing, :seeking, :stalled, :volume-locked', () => {
38993900

39003901
/**
39013902
* <html>
39023903
* <body>
3903-
* <video muted="true"></video> <!-- unmuted by the user -->
3904+
* <video muted="true"></video> <!-- the user unmuted the video -->
39043905
* <video muted></video>
39053906
* <div></div>
39063907
* </body>

test/style.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ describe('CSSStyleDeclaration.cssText', () => {
224224
assert.equal(style.cssText, 'color: green; font-size: 12px;')
225225
})
226226
})
227-
// TODO: add test for filtering declared values in @import style sheet
228227
describe('CSSStyleDeclaration.setProperty(), CSSStyleDeclaration.getPropertyValue(), CSSStyleDeclaration.removeProperty()', () => {
229228
it('throws an error when trying to set or remove a declaration while the readonly flag is set', () => {
230229
const style = createStyle({ readOnly: true })

test/value.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,6 @@ describe('<signed-integer>', () => {
12761276
assert.valid('<signed-integer>', `+${MAX_INTEGER + 1}`, `+${MAX_INTEGER}`)
12771277
})
12781278
})
1279-
// TODO: add support for variable units
12801279
describe('<dimension>', () => {
12811280
test('invalid', () => {
12821281
// Invalid identifier (start) code point
@@ -2359,7 +2358,7 @@ describe('<random()>', () => {
23592358
assert.valid('<number>', 'random(fixed 1, infinity, 1)', 'calc(infinity)', styleRule)
23602359
assert.valid('<number>', 'random(fixed 1, -infinity, 1)', 'calc(-infinity)', styleRule)
23612360
// Discarded step when its multiplier is infinite
2362-
assert.valid('<number>', 'random(fixed 0.1, 0, 1, 0)', `calc(0.1)`, styleRule)
2361+
assert.valid('<number>', 'random(fixed 0.1, 0, 1, 0)', 'calc(0.1)', styleRule)
23632362
})
23642363
})
23652364
describe('<sibling-count()>, <sibling-index()>', () => {

0 commit comments

Comments
 (0)