From b43762d3a81cc2ea4cadbc65d541a99b28618c82 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 9 Dec 2019 17:49:14 -0500 Subject: [PATCH] ci failures. clutching at straws --- .eslintignore | 1 + package-lock.json | 6 +- package.json | 2 +- .../wrappers/shared/get_slot_definition.ts | 73 +++++++------------ 4 files changed, 33 insertions(+), 49 deletions(-) diff --git a/.eslintignore b/.eslintignore index a0ca1e55c8..d1f48d6493 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ **/_actual.js **/expected.js +**/_output/**.js test/*/samples/*/output.js node_modules diff --git a/package-lock.json b/package-lock.json index 93e762b3a8..97a19aeb6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -500,9 +500,9 @@ "dev": true }, "code-red": { - "version": "0.0.26", - "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.26.tgz", - "integrity": "sha512-W4t68vk3xJjmkbuAKfEtaj7E+K82BtV+A4VjBlxHA6gDoSLc+sTB643JdJMSk27vpp5iEqHFuGnHieQGy/GmUQ==", + "version": "0.0.27", + "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.27.tgz", + "integrity": "sha512-MSILIi8kkSGag76TW+PRfBP/dN++Ei+uTeiUfqW4Es5teFNrbsAWtyAbPwxKI1vxEsBx64loAfGxS1kVCo1d2g==", "dev": true, "requires": { "acorn": "^7.1.0", diff --git a/package.json b/package.json index fb1d7cbad3..4d115cb778 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "acorn": "^7.1.0", "agadoo": "^1.1.0", "c8": "^5.0.1", - "code-red": "0.0.26", + "code-red": "0.0.27", "codecov": "^3.5.0", "css-tree": "1.0.0-alpha22", "eslint": "^6.3.0", diff --git a/src/compiler/compile/render_dom/wrappers/shared/get_slot_definition.ts b/src/compiler/compile/render_dom/wrappers/shared/get_slot_definition.ts index 44fc980c9d..2adbd3b1d0 100644 --- a/src/compiler/compile/render_dom/wrappers/shared/get_slot_definition.ts +++ b/src/compiler/compile/render_dom/wrappers/shared/get_slot_definition.ts @@ -31,62 +31,45 @@ export function get_slot_definition(block: Block, scope: TemplateScope, lets: Le const { context_lookup } = block.renderer; - let expression; - // i am well aware that this code is gross // TODO make it less gross const changes = { - get type() { - if (block.renderer.context_overflow) return 'ArrayExpression'; + type: 'ParenthesizedExpression', + get expression() { + if (block.renderer.context_overflow) { + const grouped = []; - expression = Array.from(names) - .map(name => { + Array.from(names).forEach(name => { const i = context_lookup.get(name).index.value as number; - return x`${name} ? ${1 << i} : 0`; - }) - .reduce((lhs, rhs) => x`${lhs} | ${rhs}`) as BinaryExpression; - - return expression.type; - }, - get elements() { - const grouped = []; + const g = Math.floor(i / 31); - Array.from(names).forEach(name => { - const i = context_lookup.get(name).index.value as number; - const g = Math.floor(i / 31); + if (!grouped[g]) grouped[g] = []; + grouped[g].push({ name, n: i % 31 }); + }); - if (!grouped[g]) grouped[g] = []; - grouped[g].push({ name, n: i % 31 }); - }); + const elements = []; - const elements = []; + for (let g = 0; g < grouped.length; g += 1) { + elements[g] = grouped[g] + ? grouped[g] + .map(({ name, n }) => x`${name} ? ${1 << n} : 0`) + .reduce((lhs, rhs) => x`${lhs} | ${rhs}`) + : x`0`; + } - for (let g = 0; g < grouped.length; g += 1) { - elements[g] = grouped[g] - ? grouped[g] - .map(({ name, n }) => x`${name} ? ${1 << n} : 0`) - .reduce((lhs, rhs) => x`${lhs} | ${rhs}`) - : x`0`; + return { + type: 'ArrayExpression', + elements + }; } - return elements; - }, - get test() { - return expression.test; - }, - get consequent() { - return expression.consequent; - }, - get alternate() { - return expression.alternate; - }, - get left() { - return expression.left; - }, - get right() { - return expression.right; - }, - operator: '|' + return Array.from(names) + .map(name => { + const i = context_lookup.get(name).index.value as number; + return x`${name} ? ${1 << i} : 0`; + }) + .reduce((lhs, rhs) => x`${lhs} | ${rhs}`) as BinaryExpression; + } }; return {