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

Update spec to include img in allowed-descendants for amp-mega-menu #7652

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bin/amphtml-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ def ParseRules(repo_directory, out_dir):

bento_spec_names = {}

# Extension to include `IMG` as allowed descendant.
allow_img_as_descendant = [
'amp-story-player-allowed-descendants',
'amp-mega-menu-allowed-descendants',
]
Comment on lines +365 to +368
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, allowing these to keep native img.


for (field_desc, field_val) in rules.ListFields():
if 'tags' == field_desc.name:
for tag_spec in field_val:
Expand Down Expand Up @@ -426,8 +432,8 @@ def ParseRules(repo_directory, out_dir):
if 'I-AMPHTML-SIZER' == val:
continue

# The img tag is currently exclusively to transformed AMP, except as descendant of amp-story-player.
if 'IMG' == val and 'amp-story-player-allowed-descendants' != _list.name:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

amp-story-player-allowed-descendants was allowed to keep native img but spec adds it for transformed AMP 🤔

https://github.com/ampproject/amphtml/blob/4ce3cd79520dbeaf5ed5364cbff58d3d71dee40e/extensions/amp-story-player/validator-amp-story-player.protoascii#L32

# The img tag is currently exclusively to transformed AMP, except few cases.
if 'IMG' == val and _list.name not in allow_img_as_descendant:
continue

descendant_lists[_list.name].append( val.lower() )
Expand Down
1 change: 1 addition & 0 deletions includes/sanitizers/class-amp-allowed-tags-generated.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading