Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(55)

Issue 40490043: Node.bind(name, observable) (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by rafaelw
Modified:
11 years, 11 months ago
Reviewers:
arv, John Messerly
Base URL:
https://github.com/Polymer/NodeBind.git@master
Visibility:
Public.

Description

Node.bind(name, observable) This patch changes the Node.bind so that bind always takes a binding name and an observable. The implication of this is that creating observers is now always the concern of TemplateBinding (and in some case the registered delegate). Note that NodeBinding is now gone. The observable is now serving the same purpose the NodeBinding was. R=arv BUG= Committed: https://github.com/Polymer/NodeBind/commit/0a09c0c

Patch Set 1 #

Patch Set 2 : cleanup #

Patch Set 3 : observable #

Patch Set 4 : cleanup #

Patch Set 5 : even moar #

Total comments: 16

Patch Set 6 : cr changes #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+216 lines, -238 lines) Patch
M src/NodeBind.js View 1 2 3 4 5 5 chunks +175 lines, -196 lines 12 comments Download
M tests/tests.js View 1 2 3 4 5 28 chunks +41 lines, -42 lines 0 comments Download

Messages

Total messages: 6
rafaelw
12 years ago (2013-12-10 22:59:34 UTC) #1
arv
Nice. I like the direction this is going. https://codereview.appspot.com/40490043/diff/60001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/40490043/diff/60001/src/NodeBind.js#newcode66 src/NodeBind.js:66: bindings[name] ...
12 years ago (2013-12-11 15:52:27 UTC) #2
rafaelw
https://codereview.appspot.com/40490043/diff/60001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/40490043/diff/60001/src/NodeBind.js#newcode66 src/NodeBind.js:66: bindings[name] = undefined; This is critical path. I don't ...
12 years ago (2013-12-11 23:36:27 UTC) #3
rafaelw
Committed patchset #6 manually as r0a09c0c (presubmit successful).
12 years ago (2013-12-12 18:09:34 UTC) #4
John Messerly
(some comments I had from porting this) https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js File src/NodeBind.js (right): https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode93 src/NodeBind.js:93: return value ...
11 years, 12 months ago (2013-12-19 19:47:41 UTC) #5
rafaelw
11 years, 11 months ago (2013-12-21 01:39:03 UTC) #6
Message was sent while issue was closed.
https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js
File src/NodeBind.js (right):

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode93
src/NodeBind.js:93: return value === undefined || value === null ? '' : value;
On 2013/12/19 19:47:43, John Messerly wrote:
> I was about to make the same comment as arv@ here:
> https://codereview.appspot.com/40490043/diff/60001/src/NodeBind.js#newcode89
> 
> looks like maybe it wasn't uploaded

Done.

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode212
src/NodeBind.js:212: observable.close = function() {
Yup. That's how to do it (and how this code recently was doing it). This way
just avoids a little bit of allocation.

On 2013/12/19 19:47:43, John Messerly wrote:
> any idea how this design would work if you couldn't monkeypatch "close"?
> 
> I'm creating a wrapper object that forwards all the method calls except close
> (basically keeping most of the old InputBinding type around). Does that seem
> reasonable?

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode310
src/NodeBind.js:310: var selectBinding = select.bindings.value;
On 2013/12/19 19:47:43, John Messerly wrote:
> not a big deal but I find it cleaner to put the "var" outside like the old
code
> had, if it is going to be used outside of the block. Someday if/when the world
> moves to "let" and block scoping it will be nice to use that over "var"
whenever
> possible.

Done.

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode314
src/NodeBind.js:314: option.value = sanitizeValue(value);;
On 2013/12/19 19:47:43, John Messerly wrote:
> extra semicolon

Done.

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode317
src/NodeBind.js:317: selectBinding.setValue(select.value);
I'm not sure. This is probably a question which will need to be answered in the
spec. I would feel free to implement what you think makes sense.

The JS code is taking a "let things fail when they fail approach" rather than
"detect possible failures early" -- mostly out of a perf concern.

On 2013/12/19 19:47:43, John Messerly wrote:
> Should this test if setValue is present? In other words, if an observer is
used
> for a two-way bindable property and it doesn't implement setValue, is it an
> error? PathObserver was pretty forgiving about that; it just dropped the new
> value.
> 
> (I'm wondering if my base implementation of observer.setValue should do
nothing,
> or throw an error indicating an unsupported operation...)

https://codereview.appspot.com/40490043/diff/80001/src/NodeBind.js#newcode318
src/NodeBind.js:318: selectBinding.reset();
For two-way bindings at least, we'll always want to reset it. The reason is a
worry that some other code will set the bound value back to what it's state
immediately preceding the user input. In that case, the observer will think that
nothing had changed, but the binding will now be out of sync with the input
value.

On 2013/12/19 19:47:43, John Messerly wrote:
> out of curiosity, do we ever want to setValue and not follow it immediately
with
> a reset?
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b