-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
amp-bind: Support bindings in fixed layer #16130
amp-bind: Support bindings in fixed layer #16130
Conversation
/to @jridgewell For review of fixed layer. Will add tests if you think this approach is ok. |
extensions/amp-bind/0.1/bind-impl.js
Outdated
return this.initialize_(body, head && elementByTag(head, 'title')); | ||
const title = head && elementByTag(head, 'title'); | ||
const fixedLayer = this.viewport_.getFixedLayerContainer(); | ||
return this.initialize_(body, fixedLayer, title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use document
as the root, instead of body
? Then you don't need to be aware of the fixed layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to avoid scanning the head unnecessarily, but this is a lot cleaner. Thanks.
e544782
to
74571da
Compare
src/amp-events.js
Outdated
// Values start at 801 for easier code searchability and to avoid conflation | ||
// with HTTP status codes. | ||
DOM_UPDATE: 801, | ||
// The following codes are only used for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we depend on the built
signal for owner elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks.
src/amp-events.js
Outdated
ERROR: 'amp:error', | ||
// Values start at 801 for easier code searchability and to avoid conflation | ||
// with HTTP status codes. | ||
DOM_UPDATE: 801, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing to numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis build failed due to bundle-size. This saves 0.03KB. 😄 We'll end up doing the same with error messages which should save a bunch more.
Had to change back to strings to avoid conversion for event type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually realized FixedLayer
doesn't need to dispatch DOM_UPDATE (at least for amp-bind) since it doesn't add new elements but just moves them on/off the transfer layer.
Still would be nice to keep this change for a small size reduction.
src/amp-events.js
Outdated
LOAD_START: 'e5', | ||
LOAD_END: 'e6', | ||
ERROR: 'e7', | ||
VISIBILITY_CHANGE: 'e8', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ads uses this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only saw usage in test code but upon closer inspection it's actually externally visible. 🤦♂️
Additionally, one can observe the amp:visibilitychange on the window object to be notified about changes in visibility.
https://github.com/ampproject/amphtml/blob/master/ads/README.md#page-visibility
Updated the unit test to use the string literal to catch this.
src/amp-events.js
Outdated
ERROR: 'amp:error', | ||
// Use short, unique strings to reduce bundle size impact. | ||
BUILT: 'e1', | ||
DOM_UPDATE: 'e2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Date picker, lightbox, list, forms, access, and FX uses this one.
src/amp-events.js
Outdated
LOAD_END: 'amp:load:end', | ||
ERROR: 'amp:error', | ||
// Use short, unique strings to reduce bundle size impact. | ||
BUILT: 'e1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure 30b is worth changing these, especially once we strip out the testing ones. Error messages are a special case because they are usually very long messages, these aren't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, don't feel strongly enough to fight ya. 😉
@jridgewell Ping. :) |
Fixes #14888.