Skip to content

[REBASED TO DEATH] Implement show and toggle as standard actions#7658

Closed
alanorozco wants to merge 88 commits intoampproject:masterfrom
alanorozco:toggle-everywhere
Closed

[REBASED TO DEATH] Implement show and toggle as standard actions#7658
alanorozco wants to merge 88 commits intoampproject:masterfrom
alanorozco:toggle-everywhere

Conversation

@alanorozco
Copy link
Copy Markdown
Member

@alanorozco alanorozco commented Feb 18, 2017

Refer to #7785

@alanorozco alanorozco changed the title Implement show as a standard action Implement show and toggle as standard actions Feb 18, 2017
}

/**
* Expands the element, resetting its default display value, and notifies its
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

{@link expandedCallback}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whoops, thanks.

* @param {!./action-impl.ActionInvocation} invocation
*/
handleToggle(invocation) {
if (getStyle(dev().assertElement(invocation.target), 'display') == 'none') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should use getComputed style here so if element is hidden some other way (e.g. author defined CSS class) we toggle properly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. Using vsync to avoid layout thrashing.


});

describe('"toggle" action', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and a test here to handle the comment above about computedStyle. Something along the lines of creating a style tag with a class like .hide { display: none } and using that class instead of display=none.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. Stubbed vsync and added elements to the body tag in the test so that getComputedStyle can work properly.

standardActions.handleShow({target: element});
expect(deferMutateStub).to.be.calledOnce;
expect(deferMutateStub.firstCall.args[0]).to.equal(element);
expect(element.expand).to.be.calledOnce;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also expectElementToHaveBeenShown(element); here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

expectElementToHaveBeenShown does not expect an AMP element. Extracted functions for AMP elements.

});

it('should handle AmpElement', () => {
const element = createAmpElement();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's also add a test where an AMP document is hidden using layout=nodisplay and then a show action is called on it ensuring display:none added by layout=nodisplay goes away after the action.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It looks like using nodisplay sets the display value of the element to none.

To be able to create this test, a test iframe would have to be constructed and then a specific AMP element would have to be installed in the iframe. I'm not sure if it's worth it to add this case since AFAICT the internal implementation would be the same regardless.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

true, nodisplay is equal to elem.style.display=none test case

mrjoro and others added 10 commits February 21, 2017 20:08
…ject#7713)

* Updated CSS for amp-selector so the outline is less specific. (Issue ampproject#7534)

* Added new line at end of file.
* first draft

* added details inline; added quick start

* added a preface for doc/test/etc. changes

* minor fixes

* responding to review comments; adding README
…#7619)

* initial changes

* add test coverage

* remove dependency on createIframePromise causing type check failure

* build failures

* build fix

* fix test failure

* change AV config from urls to url

* PR review

* Add scoped attribute to amp-analytics

* fix lint error

* fix lint error

* fix presubmit error
…roject#7709)

* Pass nocurls as additional info to Viewer for latency tracking.

* Add test.

* use urls.cdn

* Add comment.

* ...

* ...

* rename experiment name

* fix test
…xception (ampproject#7723)

* Only use local storage if the API is declared and does not throw an exception (ampproject#6633)

* Revert "Only use local storage if the API is declared and does not throw an exception (ampproject#6633)"

This reverts commit fb0f11f.

* Only use local storage if the API is declared and does not throw an exception (ampproject#6633)

* Fix whitespace lint issue

* Ensure that getItem is not called when attempting to load an item from local storage when local storage is not supported.
* Detect JS Engine when reporting errors

This should save us some time trying to determine what the real browser
is, not what the UserAgent is masquerading as.

* Fix IE detection

Also add comments

* linting

* JSDoc

* Add error tests to integrations suite

* Fix closure type check
@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@alanorozco alanorozco changed the title Implement show and toggle as standard actions [REBASED TO DEATH] Implement show and toggle as standard actions Feb 24, 2017
@alanorozco
Copy link
Copy Markdown
Member Author

Closing due to rebase issue.

New PR is #7785

@alanorozco alanorozco closed this Feb 24, 2017
@alanorozco alanorozco deleted the toggle-everywhere branch March 23, 2017 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.