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

#setOwner should rewrite resource.owner_ value if it exist #5898

Merged
merged 3 commits into from Oct 31, 2016

Conversation

zhouyx
Copy link
Contributor

@zhouyx zhouyx commented Oct 28, 2016

extend #3595
fix #5862

I didn't fix nested element owner update in this PR.

@@ -99,6 +99,9 @@ export class Resource {
*/
static setOwner(element, owner) {
dev().assert(owner.contains(element), 'Owner must contain the element');
if (Resource.forElementOptional(element)) {
Resource.forElementOptional(element).owner_ = owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how I feel about touching someone else's private property. If we keep the #setOwner instance method, we could just call that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can have another non static setOwner method in resource class which we use to set this.owner_?

@zhouyx
Copy link
Contributor Author

zhouyx commented Oct 28, 2016

To solve the nested element owner change, I can't use resource.owner_ to cache the value. I feel there will be a performance issue. Then I thought about manually update all childrens' resource.owner_ value if they have one, but that's even worse I think, because you never know how many children one element can have. Ideas?

@zhouyx
Copy link
Contributor Author

zhouyx commented Oct 28, 2016

I don't think we can make #setOwner an instance method. so I added a #updateOwner instance method and call that in #setOwner

@jridgewell
Copy link
Contributor

Looks fine to me, deferring to @dvoytenko.

@zhouyx zhouyx merged commit 7ae082b into ampproject:master Oct 31, 2016
@zhouyx zhouyx deleted the setOwner branch October 31, 2016 15:55
samiamorwas pushed a commit to samiamorwas/amphtml that referenced this pull request Oct 31, 2016
…mp_reddit_extension

* 'master' of https://github.com/ampproject/amphtml: (121 commits)
  `#setOwner` should rewrite `resource.owner_` value if it exist (ampproject#5898)
  Defer full upgrade until the element is connected (ampproject#5908)
  Skeleton for an amp-animation component (ampproject#5891)
  Use upgrade callback to pick the correct carousel class. (ampproject#5899)
  Add alert role to user-notification by default (ampproject#5896)
  Fix test-iframe-createIframeWithMessageStub failures on older browsers (ampproject#5895)
  Make screen readers announce changes in the slides carousel. (ampproject#5892)
  Separate out implementaton of document-info and remove dependency of … (ampproject#5864)
  Fixed assertion in key fetch function. (ampproject#5854)
  Track impression on amp landing page (ampproject#5606)
  Backward compatible way of stringifying Uint8Array (ampproject#5881)
  Ensure that a friendly-iframe embed cancels any boilerplate when ready (ampproject#5863)
  Fix amp-forms broken and flakey tests. (ampproject#5835)
  Make SW test properly skip when Request == undefined (ampproject#5876)
  Add Preamble section to AMP Cache Guidelines (ampproject#5873)
  Adding Adverline to amp-ad (ampproject#5829)
  Clarify cache guidelines (ampproject#5874)
  Consider it as non-viewer mode if there is no "origin" in hash param. (ampproject#5867)
  [amp-youtube] autoplay and test suite to run across all video players that implement the video API (ampproject#5765)
  Update Forms Docs to reflect availability. (ampproject#5815)
  ...
lannka pushed a commit that referenced this pull request Oct 31, 2016
* fix

* add test

* add instance method to update owner value
@jridgewell jridgewell mentioned this pull request Nov 8, 2016
1 task
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
…oject#5898)

* fix

* add test

* add instance method to update owner value
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
…oject#5898)

* fix

* add test

* add instance method to update owner value
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.

amp-sticky-ad fails to load sometimes on Safari 10
3 participants