https://jsbin.com/noloqox/edit?js,output in a gist
Last active
February 7, 2018 20:37
-
-
Save phillipskevin/f82b2b22d0664f4a484de65afa3bd824 to your computer and use it in GitHub Desktop.
can-view-live memory leak
This file contains 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> | |
<script src="./node_modules/steal/steal.js"></script> |
This file contains 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
import nodeLists from "can-view-nodelist"; | |
import DefineMap from "can-define/map/map"; | |
import DefineList from "can-define/list/list"; | |
import stache from "can-stache"; | |
import "can-stache-bindings"; | |
var origRegister = nodeLists.register; | |
nodeLists.register = function (nodeList, unregistered, parent, directlyNested) { | |
if (parent.replacements && parent.replacements.length) { | |
console.log(parent.replacements); | |
} | |
origRegister.apply(this, arguments); | |
}; | |
var VM = DefineMap.extend({ | |
list: { | |
Type: DefineList, | |
value() { | |
return new DefineList([1, 2]); | |
} | |
}, | |
addItem() { | |
this.list.push(this.list.length + 1); | |
}, | |
removeItem() { | |
this.list.splice(0, 1); | |
} | |
}); | |
var vm = new VM(); | |
var template = stache(` | |
<ul> | |
{{#each list}} | |
<li>{{this}}</li> | |
{{/each}} | |
</ul> | |
<button on:click="addItem()">Add an item</button> | |
<button on:click="removeItem()">Remove an item</button> | |
`); | |
var frag = template(vm); | |
document.body.appendChild(frag); |
This file contains 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
{ | |
"name": "f82b2b22d0664f4a484de65afa3bd824", | |
"version": "1.0.0", | |
"description": "https://jsbin.com/noloqox/edit?js,output in a gist", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+ssh://[email protected]/f82b2b22d0664f4a484de65afa3bd824.git" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "MIT", | |
"bugs": { | |
"url": "https://gist.github.com/f82b2b22d0664f4a484de65afa3bd824" | |
}, | |
"homepage": "https://gist.github.com/f82b2b22d0664f4a484de65afa3bd824", | |
"dependencies": { | |
"can-define": "^1.5.5", | |
"can-stache": "^3.14.11", | |
"can-stache-bindings": "^3.11.10", | |
"can-view-nodelist": "^3.1.1", | |
"steal": "^1.6.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment