3 ms·
It's also calling eval() on every single data-bind attribute you have: http://github.com/SteveSanderson/knockout/blob/master/src/binding/bindingAttributeSyntax
by jashkenas 16y ago
It's also calling eval() on every single data-bind attribute you have:
http://github.com/SteveSanderson/knockout/blob/master/src/binding/bindingAttributeSyntax.js#L7-14 http://github.com/SteveSanderson/knockout/blob/master/src/bi...
Perhaps Steve can comment on how well this performs in real-world views with thousands of DOM elements...
- stevensanderson 16y agoThe evaling is a robust way to parse the JSON-like binding syntax at the full speed of the browser's native code. Much faster than implementing the parsing in JavaScript.
- jashkenas 16y agoJust to be clear -- the "JSON-like binding syntax" includes arbitrary JavaScript code, right? That's how stuff like this works... <button data-bind="click: function() { allItems.sort() }, enable: allItems().length > 1"> Sort </button>
- stevensanderson 16y agoIt can do in cases where you find that more convenient. Whenever you prefer to move logic into your view model and just reference it, you can do so. It's intended to be flexible.