From 936cdbd3c51ef87e4cfad5d33ccba078af80b281 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 11 Dec 2021 19:42:18 +0100 Subject: [PATCH] Make during...spawn linked actors always exempt from root facet inert check --- packages/compiler/src/compiler/codegen.ts | 9 ++++++--- packages/html/src/index.ts | 3 --- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/compiler/src/compiler/codegen.ts b/packages/compiler/src/compiler/codegen.ts index af19e89..7d45de7 100644 --- a/packages/compiler/src/compiler/codegen.ts +++ b/packages/compiler/src/compiler/codegen.ts @@ -147,7 +147,10 @@ export function expand(tree: Items, ctx: ExpansionContext): Items { } spawn.linkedToken = getRange(s.body); } - let body = (spawn == null) ? walk(s.body) : expandSpawn(spawn, t); + + let body = (spawn == null) + ? walk(s.body) + : expandSpawn(spawn, t, t`__SYNDICATE__.Turn.activeFacet.preventInertCheck();`); const sa = compilePattern(s.pattern); return t`assertDataflow(() => ({ @@ -166,7 +169,7 @@ ${joinItems(sa.captureBinders.map(binderTypeGuard(ctx, t)), '\n')} }));`; }); - function expandSpawn(spawn: SpawnStatement, t: TemplateFunction): Items { + function expandSpawn(spawn: SpawnStatement, t: TemplateFunction, inject: Items = []): Items { // TODO: parentBinders, parentInits /* let assertions = (s.initialAssertions.length > 0) @@ -174,7 +177,7 @@ ${joinItems(sa.captureBinders.map(binderTypeGuard(ctx, t)), '\n')} : ``; */ const n = spawn.name === void 0 ? '' : t` __SYNDICATE__.Turn.activeFacet.actor.name = ${walk(spawn.name)};`; - return t`__SYNDICATE__.Turn.active._spawn${spawn.linkedToken ? 'Link': ''}(() => {${n} ${walk(spawn.body)} });`; + return t`__SYNDICATE__.Turn.active._spawn${spawn.linkedToken ? 'Link': ''}(() => {${n} ${inject} ${walk(spawn.body)} });`; } x(ctx.parser.spawn, expandSpawn); diff --git a/packages/html/src/index.ts b/packages/html/src/index.ts index e3355fb..b6a2ffd 100644 --- a/packages/html/src/index.ts +++ b/packages/html/src/index.ts @@ -74,7 +74,6 @@ export function spawnWindowEventFactory(ds: Ref) { "pattern": :pattern P.WindowEvent(\Q.lit($eventType: string), \_) }) => spawn named ['WindowEvent', eventType] { const facet = Turn.activeFacet; - facet.preventInertCheck(); let handler = (event: Event) => { facet.turn(() => { @@ -349,8 +348,6 @@ function _attributeLike(selector: string, { let savedValues: Array<{node: Element, value: any}> = []; - Turn.activeFacet.preventInertCheck(); - selectorMatch(document.body, selector).forEach(node => { switch (kind) { case 'attribute':