From ba93317a9bd16bec3a843374711aafb7edb7fd32 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:11:48 +0200 Subject: [PATCH 01/16] test: diff published files --- azure-pipelines.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 734231dd..3aa8dcda 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -56,11 +56,27 @@ steps: - script: | npm pack mv dom-accessibility-api-*.tgz dom-accessibility-api.tgz - displayName: "Prepare smoke tests of build" + displayName: "Create tarball" - publish: $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz + displayName: "Publish tarball" artifact: dom-accessibility-api-node-$(node_version) + - download: specific + displayName: "Download tarball from master" + artifact: dom-accessibility-api-node-$(node_version) + path: $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz + runVersion: latestFromBranch + runBranch: refs/heads/master + + - script: | + mkdir $(Agent.TempDirectory)/published-previous + mkdir $(Agent.TempDirectory)/published-current + tar xfvz $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz --directory $(Agent.TempDirectory)/published-previous + tar xfvz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current + diff $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current + displayName: "Diff tarballs" + - script: yarn start displayName: "kcd-rollup smoke tests of build" workingDirectory: tests/build/fixtures/kcd-rollup From 44bca8e46e29cfa6a4388e635193a276fefc5be2 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:15:50 +0200 Subject: [PATCH 02/16] fix: can't use inputs for `download` alias --- azure-pipelines.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3aa8dcda..a6947824 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -62,12 +62,14 @@ steps: displayName: "Publish tarball" artifact: dom-accessibility-api-node-$(node_version) - - download: specific + - task: DownloadPipelineArtifact@2 displayName: "Download tarball from master" - artifact: dom-accessibility-api-node-$(node_version) - path: $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz - runVersion: latestFromBranch - runBranch: refs/heads/master + inputs: + artifact: dom-accessibility-api-node-$(node_version) + path: $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz + source: specific + runVersion: latestFromBranch + runBranch: refs/heads/master - script: | mkdir $(Agent.TempDirectory)/published-previous From 4180e381d96abf4f1b31fefda1092e8479c066c2 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:26:02 +0200 Subject: [PATCH 03/16] fix: specify pipeline and project to download the tarball from --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a6947824..93197157 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -68,6 +68,8 @@ steps: artifact: dom-accessibility-api-node-$(node_version) path: $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz source: specific + pipeline: $(System.DefinitionId) + project: $(System.TeamProject) runVersion: latestFromBranch runBranch: refs/heads/master From 4f1b7a5a78267d485d582d4053a56045bc353dd9 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:32:53 +0200 Subject: [PATCH 04/16] debug --- azure-pipelines.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 93197157..e161d5d0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -66,7 +66,7 @@ steps: displayName: "Download tarball from master" inputs: artifact: dom-accessibility-api-node-$(node_version) - path: $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz + path: $(Agent.TempDirectory)/artifacts-master source: specific pipeline: $(System.DefinitionId) project: $(System.TeamProject) @@ -74,9 +74,11 @@ steps: runBranch: refs/heads/master - script: | + ls $(Agent.TempDirectory)/artifacts-master + ls mkdir $(Agent.TempDirectory)/published-previous mkdir $(Agent.TempDirectory)/published-current - tar xfvz $(System.DefaultWorkingDirectory)/dom-accessibility-api-master.tgz --directory $(Agent.TempDirectory)/published-previous + tar xfvz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous tar xfvz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current diff $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current displayName: "Diff tarballs" From 339cbb6f13b150a090d44a90e2ea88c060c4aa84 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:33:25 +0200 Subject: [PATCH 05/16] REVERT LATER: reduce feedback loop --- azure-pipelines.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e161d5d0..d9f10b51 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,17 +38,6 @@ steps: yarn install displayName: "Install packages" - - script: | - yarn format - git diff --exit-code - displayName: "Check format" - - - script: yarn lint - displayName: "Lint code" - - - script: yarn test:types - displayName: "Test types" - - script: | yarn build displayName: "Build" From 51b86d36fa60125db4fe0703d69166ea42f47bd9 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:36:09 +0200 Subject: [PATCH 06/16] remove debug utils since it's passign --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d9f10b51..a861bcf2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -63,8 +63,6 @@ steps: runBranch: refs/heads/master - script: | - ls $(Agent.TempDirectory)/artifacts-master - ls mkdir $(Agent.TempDirectory)/published-previous mkdir $(Agent.TempDirectory)/published-current tar xfvz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous From 6cc0a6949e6c7f6b2052a749bb1ca9262a61db93 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:38:12 +0200 Subject: [PATCH 07/16] feat: remove one instance of for-of --- sources/accessible-name.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/accessible-name.ts b/sources/accessible-name.ts index a9674fd7..17316767 100644 --- a/sources/accessible-name.ts +++ b/sources/accessible-name.ts @@ -183,11 +183,11 @@ function querySelectorAllSubtree( element: Element, selectors: string ): Element[] { - const elements = []; + const elements = ArrayFrom(element.querySelectorAll(selectors)); - for (const root of [element, ...idRefs(element, "aria-owns")]) { + idRefs(element, "aria-owns").forEach((root) => { elements.push(...ArrayFrom(root.querySelectorAll(selectors))); - } + }); return elements; } From 10d1168e8e93b59d96e16e6896d2d2a3f0763642 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:50:44 +0200 Subject: [PATCH 08/16] silence tar output, actually diff files --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a861bcf2..aefec1a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -65,9 +65,9 @@ steps: - script: | mkdir $(Agent.TempDirectory)/published-previous mkdir $(Agent.TempDirectory)/published-current - tar xfvz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous - tar xfvz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current - diff $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current + tar xfz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous + tar xfz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current + diff -r $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current displayName: "Diff tarballs" - script: yarn start From 03d51ecc8ffb7d54da41640909cc10d9eae30c86 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 15:58:58 +0200 Subject: [PATCH 09/16] pretty diff --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aefec1a3..54fda887 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,7 +67,7 @@ steps: mkdir $(Agent.TempDirectory)/published-current tar xfz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous tar xfz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current - diff -r $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current + git --no-pager diff --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current displayName: "Diff tarballs" - script: yarn start From 9a58235c1607eb8fe50d5d335eb2a436ddf70ebe Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:04:11 +0200 Subject: [PATCH 10/16] fix: --no-exit-code with --no-index --- azure-pipelines.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 54fda887..91031858 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,7 +67,10 @@ steps: mkdir $(Agent.TempDirectory)/published-current tar xfz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous tar xfz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current - git --no-pager diff --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current + # --no-index implies --exit-code + # This task is informative only. + # Diffs are almost always expected + git --no-pager diff --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current || exit 0 displayName: "Diff tarballs" - script: yarn start From ba89f03d548bd101e1cec082d27017ca1b148256 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:06:11 +0200 Subject: [PATCH 11/16] format --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 91031858..d81e9bba 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -67,9 +67,9 @@ steps: mkdir $(Agent.TempDirectory)/published-current tar xfz $(Agent.TempDirectory)/artifacts-master/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-previous tar xfz $(System.DefaultWorkingDirectory)/dom-accessibility-api.tgz --directory $(Agent.TempDirectory)/published-current - # --no-index implies --exit-code - # This task is informative only. - # Diffs are almost always expected + # --no-index implies --exit-code + # This task is informative only. + # Diffs are almost always expected git --no-pager diff --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current || exit 0 displayName: "Diff tarballs" From 7329728ca897ec28ea202974c55ba69ca19632dc Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:12:35 +0200 Subject: [PATCH 12/16] color diff --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d81e9bba..899c6660 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -70,7 +70,7 @@ steps: # --no-index implies --exit-code # This task is informative only. # Diffs are almost always expected - git --no-pager diff --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current || exit 0 + git --no-pager diff --color --no-index $(Agent.TempDirectory)/published-previous $(Agent.TempDirectory)/published-current || exit 0 displayName: "Diff tarballs" - script: yarn start From 29eefd5c81882fbf043c28154792a26378fc5e80 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:18:12 +0200 Subject: [PATCH 13/16] Revert "REVERT LATER: reduce feedback loop" This reverts commit 339cbb6f13b150a090d44a90e2ea88c060c4aa84. --- azure-pipelines.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 899c6660..e77f6ace 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,6 +38,17 @@ steps: yarn install displayName: "Install packages" + - script: | + yarn format + git diff --exit-code + displayName: "Check format" + + - script: yarn lint + displayName: "Lint code" + + - script: yarn test:types + displayName: "Test types" + - script: | yarn build displayName: "Build" From 756e2ccacc65844d75f030ef81790c3f02e6fd6d Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:49:58 +0200 Subject: [PATCH 14/16] restrict for-of to prevent over-transpilation --- .eslintrc | 12 +++++++++++- sources/accessible-name.ts | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3e771d18..0a51c8e0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -26,6 +26,13 @@ // own implementation. See https://github.com/eps1lon/dom-accessibility-api/blob/eb868428a31a093aecc531bf2dd17e8547bd0c3b/sources/accessible-name.ts#L33 "property": "getComputedStyle" } + ], + "no-restricted-syntax": [ + "error", + { + "selector": "ForOfStatement", + "message": "for-of assumes iterators which require heavy transpilation for es5. Use ArrayFrom(...).forEach instead." + } ] }, "overrides": [ @@ -48,7 +55,10 @@ // disable previous window.getComputedStyles restriction // perf concerns for this aren't applicable to test // since we specifically want to test them - "no-restricted-properties": "off" + "no-restricted-properties": "off", + // disable previous for-of restriction + // over transpilation isn't a concern for tests + "no-restricted-syntax": "off" } } ] diff --git a/sources/accessible-name.ts b/sources/accessible-name.ts index 17316767..3ef2f334 100644 --- a/sources/accessible-name.ts +++ b/sources/accessible-name.ts @@ -314,7 +314,7 @@ export function computeAccessibleName( const childNodes = ArrayFrom(node.childNodes).concat( idRefs(node, "aria-owns") ); - for (const child of childNodes) { + childNodes.forEach((child) => { const result = computeTextAlternative(child, { isEmbeddedInLabel: context.isEmbeddedInLabel, isReferenced: false, @@ -326,7 +326,7 @@ export function computeAccessibleName( createGetComputedStyle(node, options)(node).getPropertyValue("display"); const separator = display !== "inline" ? " " : ""; accumulatedText += `${separator}${result}`; - } + }); if (isElement(node)) { const pseudoAfter = createGetComputedStyle(node, options)(node, ":after"); @@ -366,7 +366,9 @@ export function computeAccessibleName( // https://w3c.github.io/html-aam/#fieldset-and-legend-elements if (isHTMLFieldSetElement(node)) { consultedNodes.add(node); - for (const child of ArrayFrom(node.childNodes)) { + const children = ArrayFrom(node.childNodes); + for (let i = 0; i < children.length; i += 1) { + const child = children[i]; if (isHTMLLegendElement(child)) { return computeTextAlternative(child, { isEmbeddedInLabel: false, From 3e4ed2cd9ed3d68f8e2cf5b47f1e929269675a3f Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 16:55:13 +0200 Subject: [PATCH 15/16] get rid of all the bubel junk --- .eslintrc | 6 +++++- sources/accessible-name.ts | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0a51c8e0..85f31798 100644 --- a/.eslintrc +++ b/.eslintrc @@ -33,7 +33,11 @@ "selector": "ForOfStatement", "message": "for-of assumes iterators which require heavy transpilation for es5. Use ArrayFrom(...).forEach instead." } - ] + ], + // Babel transpiles array spread assuming iterators. + // If we know we have an array we cann use .apply instead. + // TypeScript will validate that claim. + "prefer-spread": "off" }, "overrides": [ { diff --git a/sources/accessible-name.ts b/sources/accessible-name.ts index 3ef2f334..ea0b400a 100644 --- a/sources/accessible-name.ts +++ b/sources/accessible-name.ts @@ -186,7 +186,8 @@ function querySelectorAllSubtree( const elements = ArrayFrom(element.querySelectorAll(selectors)); idRefs(element, "aria-owns").forEach((root) => { - elements.push(...ArrayFrom(root.querySelectorAll(selectors))); + // babel transpiles this assuming an iterator + elements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors))); }); return elements; From c943c0575629534aafedc5131cca81c986a0a441 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 16 May 2020 17:02:51 +0200 Subject: [PATCH 16/16] add changeset --- .changeset/poor-ways-film.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/poor-ways-film.md diff --git a/.changeset/poor-ways-film.md b/.changeset/poor-ways-film.md new file mode 100644 index 00000000..c25620fd --- /dev/null +++ b/.changeset/poor-ways-film.md @@ -0,0 +1,12 @@ +--- +"dom-accessibility-api": patch +--- + +Reduce over-transpilation + +Switched from + +- for-of to `.forEach` or basic for loop +- `array.push(...otherArray)` to `push.apply(array, otherArray)` + +This removed a bunch of babel junk that wasn't needed.