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

R1: schedule amp-bind targets #37619

Merged
merged 1 commit into from Feb 11, 2022
Merged

Conversation

samouri
Copy link
Member

@samouri samouri commented Feb 9, 2022

summary
Schedules an element to be laid out if it is the target of an amp-bind mutation.

Fixes #37400

// If amp-bind is trying to mutate an uninitialized BaseElement, it is probably about time
// to initialize it.
const scheduler = getSchedulerForDoc(this);
scheduler.scheduleAsap(this);
Copy link
Member

Choose a reason for hiding this comment

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

How's this different than a component setting deferredMount = false when it needs to mutate before mount?

Copy link
Member Author

@samouri samouri Feb 9, 2022

Choose a reason for hiding this comment

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

First, this affects every component instead of only a specific one.

Second, the mount of the component (build/layout) will now be deferred until the amp-bind event occurs instead of on document load. Especially for an initially hidden component it may make sense to defer initialization.

Copy link
Member

Choose a reason for hiding this comment

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

Would this allow us to remove deferredMount = false from the components that define it?

Copy link
Member Author

@samouri samouri Feb 10, 2022

Choose a reason for hiding this comment

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

The only component that does so is amp-sidebar. Answer is maybe. Unsure right now why deferredMount=false was added to begin with.

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.

Bento version of amp-lightbox does not respond to state-bound open attribute changes via amp-bind
4 participants