Created
November 24, 2015 22:04
-
-
Save samccone/8ca56643c8e1aa4f930a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
</body> | |
<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); | |
} | |
}); | |
}); | |
function roll() { | |
for(var i = 1; i < 11; ++i) { | |
setTimeout(function() { | |
document.body.appendChild(document.createElement('x-element')); | |
}, 500 * i) | |
setTimeout(function() { | |
document.body.querySelector('x-element').removeElement(); | |
}, 800 * i) | |
} | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment