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

Test layers don't multi-reference children #18269

Merged
merged 1 commit into from Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/service/layers-impl.js
Expand Up @@ -721,10 +721,10 @@ export class LayoutElement {
dev().assert(this.isLayer());
dev().assert(this.contains(child));

// Parents track the children, but not all children are aware of there
// Parents track the children, but not all children are aware of their
// parents. When a child finds its parent, it adds itself to the parent.
// This might lead to a double tracking.
if (this.children_.indexOf(child) === -1) {
if (!this.children_.includes(child)) {
this.children_.push(child);
}
}
Expand Down
20 changes: 20 additions & 0 deletions test/functional/test-layers.js
Expand Up @@ -131,6 +131,26 @@ describes.realWin('Layers', {amp: true}, env => {
expect(layer).to.equal(LayoutElement.for(parent));
});

it('does not cause double references in layer tree', () => {
const layers = Services.layersForDoc(root);
const div = createElement();
root.appendChild(div);
layers.add(div);

const layout = LayoutElement.for(div);
const rootLayout = LayoutElement.for(scrollingElement);
expect(layout.getParentLayer()).to.equal(rootLayout);

layout.forgetParentLayer();
expect(layout.getParentLayer()).to.equal(rootLayout);

const spy = sinon.sandbox.spy(div, 'getBoundingClientRect');
rootLayout.dirtyMeasurements();
rootLayout.remeasure();

expect(spy).to.have.callCount(1);
});

describe('inside FIE', () => {
let iframe;
let iframeBody;
Expand Down