Skip to content

Commit 3960e24

Browse files
committed
Editorial: update dependencies and remove polyfill of Iterator helpers
1 parent 30b6c89 commit 3960e24

File tree

8 files changed

+86
-3751
lines changed

8 files changed

+86
-3751
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v2
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
1212
with:
13-
node-version: '16.x'
13+
node-version: '23.x'
1414
- run: npm install
1515
- run: npm run build
1616
- name: commit changes
17-
uses: elstudio/actions-js-build/commit@v3
17+
uses: elstudio/actions-js-build/commit@v4
1818
with:
1919
commitMessage: "fixup: [spec] `npm run build`"

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- uses: actions/setup-node@v2
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
1111
with:
12-
node-version: "16"
12+
node-version: "23"
1313
- name: install
1414
run: npm install
1515
- name: test

__tests__/test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/// <reference path="../global.d.ts" />
2-
require("core-js/proposals/iterator-helpers")
32
require("../polyfill.js")
43

54
test("Iterator.range<number>", () => {
65
expect(that(Iterator.range(-1, 5))).toMatchInlineSnapshot(`"-1f, 0f, 1f, 2f, 3f, 4f"`)
76
expect(that(Iterator.range(-5, 1))).toMatchInlineSnapshot(`"-5f, -4f, -3f, -2f, -1f, 0f"`)
87
expect(that(Iterator.range(0, 1, 0.1))).toMatchInlineSnapshot(
9-
`"0f, 0.1f, 0.2f, 0.30000000000000004f, 0.4f, 0.5f, 0.6000000000000001f, 0.7000000000000001f, 0.8f, 0.9f"`
8+
`"0f, 0.1f, 0.2f, 0.30000000000000004f, 0.4f, 0.5f, 0.6000000000000001f, 0.7000000000000001f, 0.8f, 0.9f"`,
109
)
1110
expect(that(Iterator.range(2 ** 53 - 1, 2 ** 53, { inclusive: true }))).toMatchInlineSnapshot(
12-
`"9007199254740991f, 9007199254740992f"`
11+
`"9007199254740991f, 9007199254740992f"`,
1312
)
1413
expect(that(Iterator.range(0, 0))).toMatchInlineSnapshot(`""`)
1514
expect(that(Iterator.range(0, -5, 1))).toMatchInlineSnapshot(`""`)
@@ -42,7 +41,7 @@ test("Range to infinity", () => {
4241
test("Use with Iterator helpers", () => {
4342
expect(that(Iterator.range(0, 10).take(5))).toMatchInlineSnapshot(`"0f, 1f, 2f, 3f, 4f"`)
4443
expect(that(Iterator.range(0, 10).map((x) => x * 2))).toMatchInlineSnapshot(
45-
`"0f, 2f, 4f, 6f, 8f, 10f, 12f, 14f, 16f, 18f"`
44+
`"0f, 2f, 4f, 6f, 8f, 10f, 12f, 14f, 16f, 18f"`,
4645
)
4746
expect(Iterator.range(0n, 10n).reduce((prev, curr) => prev + curr, 0n)).toMatchInlineSnapshot(`45n`)
4847
})
@@ -54,12 +53,12 @@ test("Be an iterator", () => {
5453
})
5554

5655
test("NaN", () => {
57-
expect(()=>(Iterator.range(NaN, 0))).toThrowError()
58-
expect(()=>(Iterator.range(0, NaN))).toThrowError()
59-
expect(()=>(Iterator.range(NaN, NaN))).toThrowError()
56+
expect(() => Iterator.range(NaN, 0)).toThrowError()
57+
expect(() => Iterator.range(0, NaN)).toThrowError()
58+
expect(() => Iterator.range(NaN, NaN)).toThrowError()
6059

61-
expect(()=>(Iterator.range(0, 0, { step: NaN }))).toThrowError()
62-
expect(()=>(Iterator.range(0, 5, NaN))).toThrowError()
60+
expect(() => Iterator.range(0, 0, { step: NaN })).toThrowError()
61+
expect(() => Iterator.range(0, 5, NaN)).toThrowError()
6362
})
6463

6564
test("Step infer", () => {

build-polyfill.mjs

Lines changed: 0 additions & 11 deletions
This file was deleted.

index.html

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,7 @@
14541454
function addStepNumberText(
14551455
ol,
14561456
depth = 0,
1457+
indent = '',
14571458
special = [...ol.classList].some(c => c.startsWith('nested-')),
14581459
) {
14591460
let counter = !special && counterByDepth[depth];
@@ -1477,16 +1478,19 @@
14771478
let i = (Number(ol.getAttribute('start')) || 1) - 1;
14781479
for (const li of ol.children) {
14791480
const marker = document.createElement('span');
1480-
marker.textContent = `${i < cache.length ? cache[i] : getTextForIndex(i)}. `;
1481+
const markerText = i < cache.length ? cache[i] : getTextForIndex(i);
1482+
const extraIndent = ' '.repeat(markerText.length + 2);
1483+
marker.textContent = `${indent}${markerText}. `;
14811484
marker.setAttribute('aria-hidden', 'true');
1485+
marker.setAttribute('class', 'list-marker');
14821486
const attributesContainer = li.querySelector('.attributes-tag');
14831487
if (attributesContainer == null) {
14841488
li.prepend(marker);
14851489
} else {
14861490
attributesContainer.insertAdjacentElement('afterend', marker);
14871491
}
14881492
for (const sublist of li.querySelectorAll(':scope > ol')) {
1489-
addStepNumberText(sublist, depth + 1, special);
1493+
addStepNumberText(sublist, depth + 1, indent + extraIndent, special);
14901494
}
14911495
i++;
14921496
}
@@ -1498,6 +1502,52 @@
14981502
});
14991503
});
15001504
1505+
// Omit indendation when copying a single algorithm step.
1506+
document.addEventListener('copy', evt => {
1507+
// Construct a DOM from the selection.
1508+
const doc = document.implementation.createHTMLDocument('');
1509+
const domRoot = doc.createElement('div');
1510+
const html = evt.clipboardData.getData('text/html');
1511+
if (html) {
1512+
domRoot.innerHTML = html;
1513+
} else {
1514+
const selection = getSelection();
1515+
const singleRange = selection?.rangeCount === 1 && selection.getRangeAt(0);
1516+
const container = singleRange?.commonAncestorContainer;
1517+
if (!container?.querySelector?.('.list-marker')) {
1518+
return;
1519+
}
1520+
domRoot.append(singleRange.cloneContents());
1521+
}
1522+
1523+
// Preserve the indentation if there is no hidden list marker, or if selection
1524+
// of more than one step is indicated by either multiple such markers or by
1525+
// visible text before the first one.
1526+
const listMarkers = domRoot.querySelectorAll('.list-marker');
1527+
if (listMarkers.length !== 1) {
1528+
return;
1529+
}
1530+
const treeWalker = document.createTreeWalker(domRoot, undefined, {
1531+
acceptNode(node) {
1532+
return node.nodeType === Node.TEXT_NODE || node === listMarkers[0]
1533+
? NodeFilter.FILTER_ACCEPT
1534+
: NodeFilter.FILTER_SKIP;
1535+
},
1536+
});
1537+
while (treeWalker.nextNode()) {
1538+
const node = treeWalker.currentNode;
1539+
if (node.nodeType === Node.ELEMENT_NODE) break;
1540+
if (/\S/u.test(node.data)) return;
1541+
}
1542+
1543+
// Strip leading indentation from the plain text representation.
1544+
evt.clipboardData.setData('text/plain', domRoot.textContent.trimStart());
1545+
if (!html) {
1546+
evt.clipboardData.setData('text/html', domRoot.innerHTML);
1547+
}
1548+
evt.preventDefault();
1549+
});
1550+
15011551
'use strict';
15021552
15031553
// Update superscripts to not suffer misinterpretation when copied and pasted as plain text.
@@ -1699,6 +1749,7 @@
16991749
17001750
span[aria-hidden='true'] {
17011751
font-size: 0;
1752+
white-space: pre;
17021753
}
17031754
17041755
a {
@@ -1796,6 +1847,10 @@
17961847
font: inherit;
17971848
color: inherit;
17981849
}
1850+
/* suppress line break opportunities between `.` and `[[FieldName]]` */
1851+
var.field::before {
1852+
content: '\2060'
1853+
}
17991854
18001855
var.referenced {
18011856
color: inherit;
@@ -3207,12 +3262,12 @@
32073262
@media print {
32083263
@page :left {
32093264
@bottom-right {
3210-
content: '© Ecma International 2024';
3265+
content: '© Ecma International 2025';
32113266
}
32123267
}
32133268
@page :right {
32143269
@bottom-left {
3215-
content: '© Ecma International 2024';
3270+
content: '© Ecma International 2025';
32163271
}
32173272
}
32183273
@page :first {
@@ -3243,7 +3298,7 @@
32433298
</ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120" width="54" height="54">
32443299
<title>Menu</title>
32453300
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
3246-
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins<button class="unpin-all">clear</button></div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-control-abstraction-objects" title="Control Abstraction Objects"><span class="secnum">27</span> Control Abstraction Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-iteration" title="Iteration"><span class="secnum">27.1</span> Iteration</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-iterator-constructor" title="Properties of the Iterator Constructor"><span class="secnum">27.1.2</span> Properties of the Iterator Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-iterator.range" title="Iterator.range ( start, end, optionOrStep )"><span class="secnum">27.1.2.1</span> Iterator.range ( <var>start</var>, <var>end</var>, <var>optionOrStep</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-numeric-range-iterator-object" title="The NumericRangeIterator Object"><span class="secnum">27.1.3</span> The <dfn tabindex="-1">NumericRangeIterator</dfn> Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-create-numeric-range-iterator" title="CreateNumericRangeIterator ( start, end, optionOrStep, type )"><span class="secnum">27.1.3.1</span> CreateNumericRangeIterator ( <var>start</var>, <var>end</var>, <var>optionOrStep</var>, <var>type</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-%numericrangeiteratorprototype%-object" title="The %NumericRangeIteratorPrototype% Object"><span class="secnum">27.1.3.2</span> The %NumericRangeIteratorPrototype% Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-properties-of-the-numericrangeiterator-prototype-object-next" title="%NumericRangeIterator%.next ( )"><span class="secnum">27.1.3.2.1</span> %NumericRangeIterator%.next ( )</a></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-the-numericrangeiterator-prototype-object-@@tostringtag" title="%NumericRangeIteratorPrototype%.[@@toStringTag]"><span class="secnum">27.1.3.2.2</span> %NumericRangeIteratorPrototype%.[@@toStringTag]</a></li></ol></li></ol></li></ol></li></ol></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / December 8, 2024</h1><h1 class="title">Range proposal</h1>
3301+
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins<button class="unpin-all">clear</button></div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-control-abstraction-objects" title="Control Abstraction Objects"><span class="secnum">27</span> Control Abstraction Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-iteration" title="Iteration"><span class="secnum">27.1</span> Iteration</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-iterator-constructor" title="Properties of the Iterator Constructor"><span class="secnum">27.1.2</span> Properties of the Iterator Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-iterator.range" title="Iterator.range ( start, end, optionOrStep )"><span class="secnum">27.1.2.1</span> Iterator.range ( <var>start</var>, <var>end</var>, <var>optionOrStep</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-numeric-range-iterator-object" title="The NumericRangeIterator Object"><span class="secnum">27.1.3</span> The <dfn tabindex="-1">NumericRangeIterator</dfn> Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-create-numeric-range-iterator" title="CreateNumericRangeIterator ( start, end, optionOrStep, type )"><span class="secnum">27.1.3.1</span> CreateNumericRangeIterator ( <var>start</var>, <var>end</var>, <var>optionOrStep</var>, <var>type</var> )</a></li><li><span class="item-toggle">+</span><a href="#sec-%numericrangeiteratorprototype%-object" title="The %NumericRangeIteratorPrototype% Object"><span class="secnum">27.1.3.2</span> The %NumericRangeIteratorPrototype% Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-properties-of-the-numericrangeiterator-prototype-object-next" title="%NumericRangeIterator%.next ( )"><span class="secnum">27.1.3.2.1</span> %NumericRangeIterator%.next ( )</a></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-the-numericrangeiterator-prototype-object-@@tostringtag" title="%NumericRangeIteratorPrototype%.[@@toStringTag]"><span class="secnum">27.1.3.2.2</span> %NumericRangeIteratorPrototype%.[@@toStringTag]</a></li></ol></li></ol></li></ol></li></ol></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / January 27, 2025</h1><h1 class="title">Range proposal</h1>
32473302
32483303
<emu-clause id="sec-control-abstraction-objects" number="27">
32493304
<h1><span class="secnum">27</span> Control Abstraction Objects</h1>
@@ -3262,7 +3317,7 @@ <h1><span class="secnum">27.1.2.1</span> Iterator.range ( <var>start</var>, <var
32623317
32633318
<emu-clause id="sec-numeric-range-iterator-object">
32643319
<h1><span class="secnum">27.1.3</span> The <dfn tabindex="-1">NumericRangeIterator</dfn> Object</h1>
3265-
<p>A NumericRangeIterator object is an iterator that yields numbers. There is not a named <emu-xref href="#constructor"><a href="https://tc39.es/ecma262/#constructor">constructor</a></emu-xref> for NumericRangeIterator objects. Instead, NumericRangeIterator objects are created by the <emu-xref aoid="CreateNumericRangeIterator" id="_ref_2"><a href="#sec-create-numeric-range-iterator">CreateNumericRangeIterator</a></emu-xref> abstract operation as needed.</p>
3320+
<p>A NumericRangeIterator object is an <emu-xref href="#sec-iterator-interface"><a href="https://tc39.es/ecma262/#sec-iterator-interface">iterator</a></emu-xref> that yields numbers. There is not a named <emu-xref href="#constructor"><a href="https://tc39.es/ecma262/#constructor">constructor</a></emu-xref> for NumericRangeIterator objects. Instead, NumericRangeIterator objects are created by the <emu-xref aoid="CreateNumericRangeIterator" id="_ref_2"><a href="#sec-create-numeric-range-iterator">CreateNumericRangeIterator</a></emu-xref> abstract operation as needed.</p>
32663321
32673322
<emu-clause id="sec-create-numeric-range-iterator" type="abstract operation" aoid="CreateNumericRangeIterator">
32683323
<h1><span class="secnum">27.1.3.1</span> CreateNumericRangeIterator ( <var>start</var>, <var>end</var>, <var>optionOrStep</var>, <var>type</var> )</h1>
@@ -3277,7 +3332,7 @@ <h1><span class="secnum">27.1.3.2</span> The %NumericRangeIteratorPrototype% Obj
32773332
<ul>
32783333
<li>has properties that are inherited by all <emu-xref href="#sec-numeric-range-iterator-object" id="_ref_4"><a href="#sec-numeric-range-iterator-object">NumericRangeIterator</a></emu-xref> Objects.</li>
32793334
<li>is an <emu-xref href="#ordinary-object"><a href="https://tc39.es/ecma262/#ordinary-object">ordinary object</a></emu-xref>.</li>
3280-
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is <emu-xref href="#sec-%iteratorprototype%-object"><a href="https://tc39.es/ecma262/#sec-%iteratorprototype%-object">%IteratorPrototype%</a></emu-xref>.</li>
3335+
<li>has a <var class="field">[[Prototype]]</var> internal slot whose value is %IteratorPrototype%.</li>
32813336
<li>has the following properties:</li>
32823337
</ul>
32833338
@@ -3287,7 +3342,7 @@ <h1><span class="secnum">27.1.3.2.1</span> %NumericRangeIterator%.next ( )</h1>
32873342
</emu-clause>
32883343
<emu-clause id="sec-properties-of-the-numericrangeiterator-prototype-object-@@tostringtag">
32893344
<h1><span class="secnum">27.1.3.2.2</span> %NumericRangeIteratorPrototype%.[@@toStringTag]</h1>
3290-
<p>The initial value of the <emu-xref href="#sec-well-known-symbols"><a href="https://tc39.es/ecma262/#sec-well-known-symbols">@@toStringTag</a></emu-xref> property is the String value <code>"NumericRangeIterator"</code>.</p>
3345+
<p>The initial value of the @@toStringTag property is the String value <code>"NumericRangeIterator"</code>.</p>
32913346
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</p>
32923347
</emu-clause>
32933348
</emu-clause>

0 commit comments

Comments
 (0)