Skip to content

♻️ FixedLayer cleanup#18788

Merged
jridgewell merged 4 commits intoampproject:masterfrom
jridgewell:fixed-layer-cleanup
Oct 23, 2018
Merged

♻️ FixedLayer cleanup#18788
jridgewell merged 4 commits intoampproject:masterfrom
jridgewell:fixed-layer-cleanup

Conversation

@jridgewell
Copy link
Copy Markdown
Contributor

@jridgewell jridgewell commented Oct 17, 2018

src/dom.js Outdated
// 8 | 2 = 0x0A
// 2 - preceeding
// 8 - contains
if (pos & 0x0A) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

// file scope
const PRECEDING_OR_CONTAINS = 
    Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS;
if (pos & PRECEDING_OR_CONTAINS) {

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.


// Sort in document order.
this.sortInDomOrder_(this.elements_);
this.sortInDomOrder_();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: I liked seeing what's being sorted. Update comment at least?

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.

There's no need to pass instance variables to an instance function.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a readability nit. I.e. what are we sorting? All elements? Some elements? Something else?

});
this.elements_.splice(i, 1);
removed.push(fe);
return fe;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we prevent an element from being added more than once? Looking at setupElement_ it doesn't seem like it.

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.

Yes, we attempt to find the element's fe. If it's found, we update, else we create a new one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if (el.element == element && el.position == position) {

Does adding a single element twice with different position result in two fes?

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.

Undid these changes.

@jridgewell jridgewell merged commit 68cfea5 into ampproject:master Oct 23, 2018
@jridgewell jridgewell deleted the fixed-layer-cleanup branch October 23, 2018 03:13
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Cleanup fixed-layer

* Extract DOM order comparator

* Undo removeElement changes

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

3 participants