Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.05k stars 2.01k forks source link

dom-repeat keeps running asynchronous code after detached if chunking is enabled. #5667

Closed rubenlg closed 4 years ago

rubenlg commented 4 years ago

Description

When dom-repeat is used with chunked rendering, it schedules a requestAnimationFrame which is not cancelled when the element is disconnected from the DOM. As a result, even after the component is detached from the DOM, it keeps running code.

Live Demo

https://jsbin.com/sirelojane/1/edit?html,console,output

Steps to Reproduce

Run the script, look at the console.

Expected Results

No RAF should have been printed after the component is detached

Actual Results

There is at least a couple more.

Browsers Affected

I only tested on Chrome, but looking at the implementation of dom-repeat it should affect all of them.

Versions

Potential fix

Adding cancelAnimationFrame(this.__chunkingId); to disconnectedCallback in dom-repeat.js seems to resolve the issue, but I don't know what other consequences that could have.