Skip to content

Use #cloneNode to clone FixedLayer body#6721

Merged
jridgewell merged 2 commits intoampproject:masterfrom
jridgewell:fixed-layer-cloneNode
Dec 20, 2016
Merged

Use #cloneNode to clone FixedLayer body#6721
jridgewell merged 2 commits intoampproject:masterfrom
jridgewell:fixed-layer-cloneNode

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

Re: #6706 (comment)

Also removes a temporary fix that is no longer necessary.

const bodyId = doc.body.id;
this.fixedLayer_ = doc.createElement('body');
this.fixedLayer_.id = bodyId || '-amp-fixedlayer';
this.fixedLayer_ = doc.body.cloneNode();
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.

Can you add explicit /*deep*/ false here, to make it self documenting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Commented.

this.fixedLayer_ = doc.createElement('body');
this.fixedLayer_.id = bodyId || '-amp-fixedlayer';
this.fixedLayer_ = doc.body.cloneNode();
this.fixedLayer_.id += ' -amp-fixedlayer';
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.

This breaks the old fix. We need the actual body.id if one was specified.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not overriding, I'm appending.

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.

Yeah, I can see that. But that breaks the previous fix. All #bodyid .x will be broken by this. It should be fixedLayer_.id = doc.body.id || '-amp-fixedlayer'. Or, tbh, we can simply kill -amp-fixedlayer and always use body.id.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh man, I though id was like class. 😳

Fixed.

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.

Cool. Do the push and I'll approve.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jridgewell jridgewell force-pushed the fixed-layer-cloneNode branch 2 times, most recently from 256b2e4 to 82334c2 Compare December 16, 2016 22:09
this.fixedLayer_ = doc.createElement('body');
this.fixedLayer_.id = bodyId || '-amp-fixedlayer';
this.fixedLayer_ = doc.body.cloneNode(/* deep */ false);
this.fixedlayer.removeAttribute('style');
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 also be making class = "" ?

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.

No class is explicitly copied. For the same reason that we copy ID, to preserve the selectors.

@jridgewell jridgewell force-pushed the fixed-layer-cloneNode branch from 82334c2 to 6dd9f5f Compare December 16, 2016 22:25
Re: ampproject#6706 (comment)

Also removes a [temporary fix](ampproject#4097) that is [no longer necessary](ampproject#6033).
@jridgewell jridgewell force-pushed the fixed-layer-cloneNode branch 6 times, most recently from 6a85796 to 2080c1e Compare December 20, 2016 18:59
@jridgewell jridgewell force-pushed the fixed-layer-cloneNode branch from 2080c1e to 93aac3f Compare December 20, 2016 19:13
@jridgewell jridgewell merged commit 477f983 into ampproject:master Dec 20, 2016
@jridgewell jridgewell deleted the fixed-layer-cloneNode branch December 20, 2016 19:44
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* Use #cloneNode to clone FixedLayer body

Re: ampproject#6706 (comment)

Also removes a [temporary fix](ampproject#4097) that is [no longer necessary](ampproject#6033).

* Fix test
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* Use #cloneNode to clone FixedLayer body

Re: ampproject#6706 (comment)

Also removes a [temporary fix](ampproject#4097) that is [no longer necessary](ampproject#6033).

* Fix test
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Jan 3, 2017
* Use #cloneNode to clone FixedLayer body

Re: ampproject#6706 (comment)

Also removes a [temporary fix](ampproject#4097) that is [no longer necessary](ampproject#6033).

* Fix test
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.

3 participants