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

Optimize is_amp_allowed_attribute checking for reference points #3815

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

westonruter
Copy link
Member

Following up on #3243 we can now optimize \AMP_Tag_And_Attribute_Sanitizer::is_amp_allowed_attribute() by looking at the currently-open elements rather than traversing all the ancestor nodes to see whether an element is open. This PR implements that optimization.

@westonruter westonruter added this to the v1.5 milestone Nov 24, 2019
@googlebot googlebot added the cla: yes Signed the Google CLA label Nov 24, 2019
@westonruter westonruter modified the milestones: v1.5, v1.4.2 Nov 24, 2019
];
foreach ( $descendant_reference_points as $ancestor_name => $reference_point_spec ) {
foreach ( $descendant_reference_points as $ancestor_name => $reference_point_spec_name ) {
if ( empty( $this->open_elements[ $ancestor_name ] ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to do what the previous code did, so it's the same thing in faster.

However, I'd note that it is not technically correct, as the relationship between "some ancestor" and the descendant is not clear and could be invalid, depending on which nodes are in-between.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to think of an example that would be invalid. Do you have one in mind?

@westonruter westonruter merged commit d267863 into develop Nov 25, 2019
@westonruter westonruter deleted the optimize/allowed-reference-point-attrs branch November 25, 2019 17:13
westonruter added a commit that referenced this pull request Dec 19, 2019
* tag '1.4.2': (25 commits)
  Bump 1.4.2
  Bump 'tested up to' to 5.3.2
  Catch unfiltered requests when testing Crowsignal embed (#3956)
  Bump version 1.4.2-RC1
  Bump 'Tested up to' to 5.3.1
  Remove test case for paired browsing since broken in WP4.9 and would not pass in AMP 1.4 (#3928)
  Further refine is_exclusively_dependent and add tests (#3928)
  Only include hoverintent-js in dev mode if exclusive dependency of admin-bar (#3928)
  Include admin-bar script deps in dev mode (e.g. hoverintent-js) (#3928)
  Fix tests after security fix in WP 5.3.1 (r46896) (#3926)
  Add E2E tests to allow_failures
  Convert `theme_features` variable into `get_theme_config` function
  Only apply smooth scroll fix on 'Twenty Twenty' <= 1.0.0
  Re-add smooth scrolling fix on WP < 5.3.1
  No need to apply smooth scrolling fix for Twenty Twenty theme
  Bump stylesheet cache group after #3866 (#3880)
  Return allowed KSES tags if not an array (#3879)
  Bundle common font files for externalizing data: URLs (#3866)
  Pull the built `block-libray` package from Gutenberg SVN if it does not exists (#3847)
  Optimize is_amp_allowed_attribute checking for reference points (#3815)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants