Skip to content

Take care of missing custom element reactions - #1412

Merged
domenic merged 1 commit into
masterfrom
more-ce-reactions
Jun 29, 2016
Merged

domenic merged 1 commit into
masterfrom
more-ce-reactions

Conversation

@domenic

@domenic domenic commented Jun 9, 2016

Copy link
Copy Markdown
Member

As discussed in WICG/webcomponents#186, there
are certain scenarios where custom element reactions could be enqueued,
but the custom element reactions stack is empty. The most prominent of
these is editing operations.

We solve this issue in two parts:

  • First, introduce the backup element queue (similar to the old "base
    element queue" concept; see
    When does the base element queue matter? WICG/webcomponents#457). This takes care of
    cases like editing which cannot be solved in any other way.
  • Also, we mandate that [CEReactions] be applied to nonstandard APIs
    that modify the DOM, including a list of what we've identified so far.

Closes WICG/webcomponents#186.


Careful review appreciated. /cc @dominiccooney @kojiishi @rniwa @annevk

As discussed in WICG/webcomponents#186, there
are certain scenarios where custom element reactions could be enqueued,
but the custom element reactions stack is empty. The most prominent of
these is editing operations.

We solve this issue in two parts:

- First, introduce the backup element queue (similar to the old "base
element queue" concept; see
WICG/webcomponents#457). This takes care of
cases like editing which cannot be solved in any other way.
- Also, we mandate that [CEReactions] be applied to nonstandard APIs
that modify the DOM, including a list of what we've identified so far.

Closes WICG/webcomponents#186.
@kojiishi

kojiishi commented Jun 16, 2016 •

Copy link
Copy Markdown

Any nonstandard APIs introduced by the user agent...must also be decorated with the [CEReactions] attribute.

doesn't sound like it covers editing, CSS OM, nor CSS Animations, but you mentioned editing in the original comment, so the intention is to wrap any such internal operations with something conceptually equal to the [CEReactions] attribute?

@domenic

domenic commented Jun 16, 2016

Copy link
Copy Markdown
Member Author

doesn't sound like it covers editing, CSS OM, nor CSS Animations, but you mentioned editing in the original comment, so the intention is to wrap any such internal operations with something conceptually equal to the [CEReactions] attribute?

The intention is that IDL-based APIs are covered by [CEReactions], and things that are not IDL-based APIs, like editing, are not---they fall back to the backup element queue. It sounds like we should send a pull request to CSSOM to add [CEReactions](unless the previous consensus is overturned in WICG/webcomponents#521).

I am not familiar with the issues involved in web animations, but my guess is that they involve changing the style attribute from event loop animation frames, not from IDL-based APIs, so they would use the backup element queue.

There is no intention to wrap things that are not IDL-based APIs in some [CEReactions] equivalent. But every IDL-based API that could cause custom element reactions should get annotated with [CEReactions]---including nonstandard ones, like those listed in this patch, or ones that have been forgotten, like CSSOM.

@kojiishi

Copy link
Copy Markdown

What about editing? Pressing ENTER, DEL, or Ctrl-V can clone, remove, or append elements without going through execCommand.

@domenic

domenic commented Jun 16, 2016

Copy link
Copy Markdown
Member Author

Hmm, I thought I was pretty clear. The entire purpose of the backup element queue is to take care of those cases.

@kojiishi

Copy link
Copy Markdown

Ah, sorry, I didn't read that part carefully enough. Microtask invokes the backup queue, understood. Sorry for the trouble.

@zcorpan

zcorpan commented Jun 18, 2016

Copy link
Copy Markdown
Member

Filed w3c/csswg-drafts#200 for CSSOM.

Comment thread source
data-x="custom-element-upgrades">upgrades</span> as well.)</p>

<p>Each <span>custom element reactions stack</span> has an associated <dfn>backup element
queue</dfn>, which an initially-empty <span>element queue</span>. Elements are pushed onto the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a little weird that a stack has an associated queue. Aren't they both bound to the unit of ...?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's an alternate way to phrase it. Keeping things together seemed clearer to me...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that this kind of thing will go away if we formalize more. E.g., if a stack becomes a formalized List or Set, we wouldn't really associate other things with it. We might create a Record that holds it and some other related information I suppose... Oh well. Up to you.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see what you mean. I'll give it a shot rewriting them as separate things and see how it feels...

@annevk

annevk commented Jun 20, 2016

Copy link
Copy Markdown
Member

LGTM editorially otherwise.

@kojiishi

Copy link
Copy Markdown

LGTM, WIP patch in Blink for this change looks working good when Enter key cloned an element in contenteditable.

@domenic

domenic commented Jun 24, 2016 •

Copy link
Copy Markdown
Member Author

Based on seeing how Blink implements this and on trying to separate out the stack from from its associated helpers (backup queue and flag) and the spec getting uglier, I think I prefer to stick with the current approach instead of separating them. However, the WIP Blink patch does not match the spec very much as far as I can tell (I commented over there), so maybe we should not merge this until I understand the reason for the mismatch.

@zcorpan

zcorpan commented Jun 28, 2016

Copy link
Copy Markdown
Member

(CSSOM fixed in w3c/csswg-drafts@39be12a)

@domenic

domenic commented Jun 29, 2016

Copy link
Copy Markdown
Member Author

Some discussion with @kojiishi and updates to the Blink patch later, it seems like this is good as-is \o/

@domenic
domenic merged commit a57c887 into master Jun 29, 2016
@domenic
domenic deleted the more-ce-reactions branch June 29, 2016 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Development

Successfully merging this pull request may close these issues.

4 participants