|
2523 | 2523 | </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"> |
2524 | 2524 | <title>Menu</title> |
2525 | 2525 | <path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path> |
2526 | | - </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</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-json-object" title="The JSON Object"><span class="secnum">1</span> The JSON Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-json.israwjson" title="JSON.isRawJSON ( O )"><span class="secnum">1.1</span> JSON.isRawJSON ( <var>O</var> )</a></li><li><span class="item-toggle">◢</span><a href="#sec-json.parse" title="JSON.parse ( text [ , reviver ] )"><span class="secnum">1.2</span> JSON.parse ( <var>text</var> [ , <var>reviver</var> ] )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-internalizejsonproperty" title="InternalizeJSONProperty ( holder, name, reviver, valNode )"><span class="secnum">1.2.1</span> InternalizeJSONProperty ( <var>holder</var>, <var>name</var>, <var>reviver</var>, <ins><var>valNode</var></ins> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-shallowestcontainedjsonvalue" title="Static Semantics: ShallowestContainedJSONValue"><span class="secnum">1.2.2</span> SS: ShallowestContainedJSONValue</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-json.rawjson" title="JSON.rawJSON ( text )"><span class="secnum">1.3</span> JSON.rawJSON ( <var>text</var> )</a></li><li><span class="item-toggle">◢</span><a href="#sec-json.stringify" title="JSON.stringify ( value [ , replacer [ , space ] ] )"><span class="secnum">1.4</span> JSON.stringify ( <var>value</var> [ , <var>replacer</var> [ , <var>space</var> ] ] )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-serializejsonproperty" title="SerializeJSONProperty ( state, key, holder )"><span class="secnum">1.4.1</span> SerializeJSONProperty ( <var>state</var>, <var>key</var>, <var>holder</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-arrayliteralcontentnodes" title="Static Semantics: ArrayLiteralContentNodes"><span class="secnum">2</span> SS: ArrayLiteralContentNodes</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-propertydefinitionlist" title="Static Semantics: PropertyDefinitionList"><span class="secnum">3</span> SS: PropertyDefinitionList</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright & Software License"><span class="secnum">A</span> Copyright & Software License</a></li></ol></div></div><div id="spec-container"><h1 class="shortname">Proposal <a href="<no location>"></a><a href="https://github.com/tc39/proposal-json-parse-with-source">proposal-json-parse-with-source</a></h1><h1 class="version">Stage 3 Draft / December 8, 2022</h1><h1 class="title">JSON.parse source text access</h1> |
2527 | | -<script> |
2528 | | -// There aren't many headings, so just expand them all by default. |
| 2526 | + </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</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-json-object" title="The JSON Object"><span class="secnum">1</span> The JSON Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-json.israwjson" title="JSON.isRawJSON ( O )"><span class="secnum">1.1</span> JSON.isRawJSON ( <var>O</var> )</a></li><li><span class="item-toggle">◢</span><a href="#sec-json.parse" title="JSON.parse ( text [ , reviver ] )"><span class="secnum">1.2</span> JSON.parse ( <var>text</var> [ , <var>reviver</var> ] )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-internalizejsonproperty" title="InternalizeJSONProperty ( holder, name, reviver, valNode )"><span class="secnum">1.2.1</span> InternalizeJSONProperty ( <var>holder</var>, <var>name</var>, <var>reviver</var>, <ins><var>valNode</var></ins> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-shallowestcontainedjsonvalue" title="Static Semantics: ShallowestContainedJSONValue"><span class="secnum">1.2.2</span> SS: ShallowestContainedJSONValue</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-json.rawjson" title="JSON.rawJSON ( text )"><span class="secnum">1.3</span> JSON.rawJSON ( <var>text</var> )</a></li><li><span class="item-toggle">◢</span><a href="#sec-json.stringify" title="JSON.stringify ( value [ , replacer [ , space ] ] )"><span class="secnum">1.4</span> JSON.stringify ( <var>value</var> [ , <var>replacer</var> [ , <var>space</var> ] ] )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-serializejsonproperty" title="SerializeJSONProperty ( state, key, holder )"><span class="secnum">1.4.1</span> SerializeJSONProperty ( <var>state</var>, <var>key</var>, <var>holder</var> )</a></li></ol></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-arrayliteralcontentnodes" title="Static Semantics: ArrayLiteralContentNodes"><span class="secnum">2</span> SS: ArrayLiteralContentNodes</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-propertydefinitionlist" title="Static Semantics: PropertyDefinitionList"><span class="secnum">3</span> SS: PropertyDefinitionList</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright & Software License"><span class="secnum">A</span> Copyright & Software License</a></li></ol></div></div><div id="spec-container"><h1 class="shortname">Proposal <a href="<no location>"></a><a href="https://github.com/tc39/proposal-json-parse-with-source">proposal-json-parse-with-source</a></h1><h1 class="version">Stage 3 Draft / January 21, 2023</h1><h1 class="title">JSON.parse source text access</h1> |
| 2527 | +<code title="work around https://github.com/tc39/ecmarkup/issues/510"><script> |
| 2528 | +// Initialize to a reasonable amount of TOC expansion: |
| 2529 | +// * Expand any full nesting level up to an arbitrary limit of 20 total visible items. |
| 2530 | +// * Expand any *single-item* level while under that limit (even if that pushes over it). |
2529 | 2531 | document.addEventListener("DOMContentLoaded", function() { |
2530 | | - try { |
2531 | | - const menuItems = Array.from(document.querySelectorAll("#menu-toc li")); |
2532 | | - if (!menuItems.some(el => el.classList.has("active"))) { |
2533 | | - menuItems.forEach(el => el.classList.add("active")); |
| 2532 | + // Limit to initialization by bailing out if any parent item is already expanded. |
| 2533 | + const tocItems = Array.from(document.querySelectorAll("#menu-toc li")); |
| 2534 | + if (tocItems.some(li => li.classList.contains("active") && li.querySelector("li"))) { |
| 2535 | + return; |
| 2536 | + } |
| 2537 | +
|
| 2538 | + const selfAndSiblings = maybeEl => Array.from(maybeEl?.parentNode.children ?? []); |
| 2539 | + let currentLevelItems = selfAndSiblings(tocItems[0]); |
| 2540 | + let availableCount = 20 - currentLevelItems.length; |
| 2541 | + while (availableCount > 0 && currentLevelItems.length) { |
| 2542 | + const nextLevelItems = currentLevelItems.flatMap(li => selfAndSiblings(li.querySelector("li"))); |
| 2543 | + availableCount -= nextLevelItems.length; |
| 2544 | + if (availableCount > 0 || currentLevelItems.length === 1) { |
| 2545 | + // Expand [current-level] parent items of the next level. |
| 2546 | + for (const ol of new Set(nextLevelItems.map(li => li.parentNode))) { |
| 2547 | + ol.closest("li").classList.add("active"); |
| 2548 | + } |
2534 | 2549 | } |
2535 | | - } catch (ex) {} |
| 2550 | + currentLevelItems = nextLevelItems; |
| 2551 | + } |
2536 | 2552 | }); |
2537 | | -</script> |
| 2553 | +</script></code> |
2538 | 2554 |
|
2539 | 2555 | <emu-clause id="sec-json-object"> |
2540 | 2556 | <h1><span class="secnum">1</span> The JSON Object</h1> |
@@ -2726,7 +2742,7 @@ <h1><span class="secnum">3</span> Static Semantics: PropertyDefinitionList</h1> |
2726 | 2742 | <h1><span class="secnum">A</span> Copyright & Software License</h1> |
2727 | 2743 | |
2728 | 2744 | <h2>Copyright Notice</h2> |
2729 | | - <p>© 2022 Richard Gibson</p> |
| 2745 | + <p>© 2023 Richard Gibson</p> |
2730 | 2746 |
|
2731 | 2747 | <h2>Software License</h2> |
2732 | 2748 | <p>All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.</p> |
|
0 commit comments