From 236ce0687639a3db52743abac3c4bb75edcd1f09 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Thu, 9 Dec 2021 15:23:50 -0800 Subject: [PATCH] Propagate the effect from emu-meta steps to AOs --- src/Meta.ts | 17 ++++++++++++++++- .../generated-reference/effect-user-code.html | 2 +- test/baselines/sources/effect-user-code.html | 4 +--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Meta.ts b/src/Meta.ts index b9d59246..6184683d 100644 --- a/src/Meta.ts +++ b/src/Meta.ts @@ -3,10 +3,25 @@ import type { Context } from './Context'; import Builder from './Builder'; +import { validateEffects } from './utils'; + export default class Meta extends Builder { static elements = ['EMU-META']; - static async enter({ spec, node }: Context) { + static async enter({ spec, node, clauseStack }: Context) { + const parent = clauseStack[clauseStack.length - 1] || null; + if (node.hasAttribute('effects') && parent !== null) { + const effects = validateEffects(spec, node.getAttribute('effects')!.split(',').map(c => c.trim()), node); + for (const effect of effects) { + if (!parent.effects.includes(effect)) { + parent.effects.push(effect); + if (!spec._effectWorklist.has(effect)) { + spec._effectWorklist.set(effect, []); + } + spec._effectWorklist.get(effect)!.push(parent); + } + } + } spec._emuMetasToRender.add(node); } diff --git a/test/baselines/generated-reference/effect-user-code.html b/test/baselines/generated-reference/effect-user-code.html index 4a3c2242..23d5b626 100644 --- a/test/baselines/generated-reference/effect-user-code.html +++ b/test/baselines/generated-reference/effect-user-code.html @@ -4,7 +4,7 @@

1 UserCode ( )

The abstract operation UserCode takes no arguments. It performs the following steps when called:

-
  1. Call user code.
+
  1. Call user code.
diff --git a/test/baselines/sources/effect-user-code.html b/test/baselines/sources/effect-user-code.html index 32123a12..7610d2d7 100644 --- a/test/baselines/sources/effect-user-code.html +++ b/test/baselines/sources/effect-user-code.html @@ -7,11 +7,9 @@

UserCode ( )

-
effects
-
user-code
- 1. Call user code. + 1. Call user code.