Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-Bento children of Bento elements #33450

Merged
merged 5 commits into from
Mar 24, 2021

Conversation

dvoytenko
Copy link
Contributor

@dvoytenko dvoytenko commented Mar 23, 2021

This looks a bit like "owners" code and some of that code was moved. But a big improvement is that this approach no longer requires us to intercept a child's lifecycle - we never need to call Owners.setOwner() here. As such, the iterators have become simple static utils which I moved to the src/utils/resource-container-helper.js.

Also, notice that all lifecycle calls I made via requiresIdleCallback when available.

More specific changes are:

  1. The main changes are concentrated inside the slot.js. These are changes are very modest in size.
  2. A part of the owners-impl.js has been moved as a set of static utilities into the src/utils/resource-container-helper.js.
  3. Lots of tests have been moved from test-owners.js and added a bunch of new tests.

Partial for #30952.

@amp-owners-bot
Copy link

Hey @jridgewell! These files were changed:

src/core/resource-container-helper.js
src/core/rethrow-async.js

src/core/resource-container-helper.js Outdated Show resolved Hide resolved
src/core/resource-container-helper.js Outdated Show resolved Hide resolved
src/core/resource-container-helper.js Outdated Show resolved Hide resolved
src/core/resource-container-helper.js Outdated Show resolved Hide resolved
src/core/resource-container-helper.js Outdated Show resolved Hide resolved
@dvoytenko dvoytenko requested a review from jridgewell March 24, 2021 04:23
@samouri samouri self-requested a review March 24, 2021 17:42
Dima Voytenko added 2 commits March 24, 2021 11:37
@dvoytenko dvoytenko merged commit 89dd3df into ampproject:master Mar 24, 2021
@dvoytenko dvoytenko deleted the bento/pause-v0 branch March 24, 2021 22:26
} else {
// Breadth-first search. Rely on the `getElementsByClassName` DOM order
// to ignore DOM subtrees already covered.
seen = seen || [];
Copy link
Member

Choose a reason for hiding this comment

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

should this be a Set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied it from owners-impl.js. But the reason it's not a set is because the test is not seen.contains(target), but seen.some(x => x.contains(target)). The uniqueness of seen itself is guaranteed by the querySelectorAll. Do you think those cases are still improved by using a set?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, iterating a Set is considerably slower than iterating an array. Given we must do a some, the Array is the right choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. That's what I figured as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants