Skip to content

Instantly share code, notes, and snippets.

@beauwest
Created November 24, 2015 18:24
Show Gist options
  • Save beauwest/f3398c59ed7542461598 to your computer and use it in GitHub Desktop.
Save beauwest/f3398c59ed7542461598 to your computer and use it in GitHub Desktop.
Example of the Polymer `down` gesture memory leak
<!DOCTYPE html>
<html>
<head>
<title>Polymer</title>
<script src="http://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
<link href="http://polygit.org/polymer+v1.2.3/components/polymer/polymer.html" rel="import">
</head>
<body>
<dom-module id="x-element">
<template>
<button id="remove">Remove Element</button>
</template>
</dom-module>
<script>
HTMLImports.whenReady(function () {
Polymer({
is: 'x-element',
listeners: {
'down': 'doNothing',
'remove.tap': 'removeElement'
},
doNothing: function () {
console.log('->movefn-><function scope>->first closure: has a reference to the leaked <button> element.');
console.log('->upfn-><function scope>->first closure: has a reference to the leaked <button> element.');
console.log(Polymer.Gestures.gestures.down.info);
console.log('');
console.log('The `down` is what is causing the leak.');
},
removeElement: function () {
Polymer.dom(Polymer.dom(this).parentNode).removeChild(this);
}
});
});
</script>
<x-element></x-element>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment