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

Roll forward "Delegate trust check... (#21553)" #21653

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented Apr 1, 2019

Roll forward #21553 with type and test fixes.

@dreamofabear dreamofabear changed the title Roll forward #21553 Roll forward "Delegate trust check... (#21553)" Apr 1, 2019
@dreamofabear
Copy link
Author

/to @alabiaga

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

We must have more action handlers then this. What about the default handlers? Do they need to be updated too?

* @private
*/
function isAmpTagName(lowercaseTagName) {
return lowercaseTagName.substring(0, 4) === 'amp-';
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

In the second usage we only have a string (attribute value).

Copy link
Contributor

Choose a reason for hiding this comment

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

Extract out of isAmpElementTagName? Either way, you're missing amp-body and amp-sticky-ad-top-padding, which are not AMP elements.

Copy link
Author

Choose a reason for hiding this comment

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

Semantics for actions are a bit more complex/confusing e.g. <script id="amp-access"> is not an AMP element but we allow invoking actions on it, so I'd rather not conflate the two by calling isAmpElement() or similar.

Maybe it should be called "isAmpTarget" rather than "isAmpTagName" though.

Tangent: I actually think isAmpElement's explicit check for amp-body etc. isn't great. We should probably duck-type check instead e.g. !!element.isLayoutSupported.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tangent: I actually think isAmpElement's explicit check for amp-body etc. isn't great. We should probably duck-type check instead e.g. !!element.isLayoutSupported.

It's intentional because we can't trust that the element has been upgraded already.

@dreamofabear
Copy link
Author

We must have more action handlers then this. What about the default handlers? Do they need to be updated too?

Most action handlers are registered on the custom element. This is only for non-CE extensions e.g. form, access. See the comment I added on installActionHandler.

@dreamofabear dreamofabear merged commit 5763c3b into ampproject:master Apr 3, 2019
@dreamofabear dreamofabear deleted the roll-forward-delegate-action-trust branch April 3, 2019 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants