googlearchive / nodebind Goto Github PK
View Code? Open in Web Editor NEWNodeBind Prolyfill
NodeBind Prolyfill
What is a "prolyfill"? How much does it differ from a _poly_fill?
I'm finding that when I use the input type=number element I get strings instead of numbers.
I want to propose a change to at part of the code
to include this:
if (input.type==='number')
observable.setValue(input.valueAsNumber);
else
observable.setValue(input[property]);
This then stores the user input as a number type
If possible make dependencies explicit and don't just "wait" for things to happen.
In https://github.com/Polymer/NodeBind/blob/master/src/NodeBind.js#L376 the code depends on the delaying actions.
This has been filed for dartlang: https://code.google.com/p/dart/issues/detail?id=13968
<input value="{{foo}}"> works.
however, if I have this model, where the input property is a reference to the element:
model = {input: input};
a binding to input.value does not work:
<div>{{input.value}}</div>
Can this be fixed?
Currently it is not published to npm.
We're planning on using this in atom, and would like to use an npm distributed version.
moved from TemplateBinding: googlearchive/TemplateBinding#82
The idea here is that it's often useful to have a selector whose value is a domain object.
IOW
model = {
users: [{ name: 'Bob', id: 1}, { name: 'Sally', id: 2}];
selected: undefined
}
<select value={{ selected }}>
<option template repeat="{{ user in users }}" value="{{ user }}">{{ user.name }}</option>
</select>
We can special case this to avoid extra allocations.
Polymer supports this following kind of thing:
<div on-click="{{ myClickHandler }}"></div>
It does this at the polymer-expressions layer. I think this is very common behavior and should be a concern of element's NodeBind.
Here's how I propose this work:
HTMLElement allows binding to 'on-', by setting up a binding to the event whose name is the first N non-whitespace characters following 'on-'. The behavior of the binding is to
addEventListener(name, function(e) {
var fn = observable.getValue();
if (typeof fn == 'function')
fn(e);
else
console.warn('cannot invoke non-function: ' + fn);
});
One thing to note here is that the bindingValue doesn't really need to be an observer, even though it is dynamic. It's sufficient to retrieve the value when the event is handled.
Thus the implementation of the element that handles the binding might not call open(), but only getValue() on the observable.
As far as I can see it's not possible to loop over an object, despite this being extremely logical in certain cases (say we have a dedicated element showing a list of tests, document.getElementById('testList').tests.someTest.correct=0
would be a sensible interface, however this isn't really possible with the NodeBind setup right now (as far as I was able to find out)). Is there any specific reason this is not supported? Especially the in
syntax suggests it should work, but at least on the stable version this doesn't seem to be working.
Just to be clear here, I talking about
<template repeat="{{a in b}}">
c
</template>
where b
is {a:'b',c:'d'}
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.