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

✨ amp-next-page: Allow hiding of arbitrary elements in child pages #15150

Merged
merged 3 commits into from May 10, 2018

Conversation

peterjosling
Copy link
Contributor

Primary use case is hiding repeated page headers/footers.

  • Reads from hideSelectors key in config
  • Blacklists i-amphtml-* selectors, like the validator
  • Runs querySelectorAll() for all the selectors when the shadow document is attached. Generating and injecting CSS would presumably be more efficient but would need more validation/sanitisation on the selectors. AFAIK passing user input directly to querySelectorAll should be safe.

@peterjosling
Copy link
Contributor Author

@aghassemi

@peterjosling peterjosling force-pushed the next-page/element-hiding branch 3 times, most recently from 04d51e8 to 9e3af68 Compare May 8, 2018 16:19
- Reads from hideSelectors key in config
- Blacklists i-amphtml-* selectors, like the validator
- Runs querySelectorAll() for all the selectors when the shadow document is attached. Generating and injecting CSS would presumably be more efficient but would need more validation/sanitisation on the selectors. AFAIK passing user input directly to `querySelectorAll` should be safe.
@aghassemi aghassemi self-requested a review May 10, 2018 00:09
function assertSelectors(selectors) {
selectors.forEach(selector => {
BANNED_SELECTOR_PATTERNS.forEach(pattern => {
user().assert(typeof selector === 'string',
Copy link
Contributor

Choose a reason for hiding this comment

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

user().assertString

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, and updated other usages.

win.dispatchEvent(new Event('scroll'));
yield macroTask();

const shadowDoc = attachShadowDocSpy.firstCall.returnValue.ampdoc;
Copy link
Contributor

Choose a reason for hiding this comment

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

@aghassemi @peterjosling This test is causing widespread unit test failures on master today: https://travis-ci.org/ampproject/amphtml/jobs/377848593#L2008

Can you fix this test, or skip if the fix isn't obvious?

Copy link
Contributor

Choose a reason for hiding this comment

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

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