Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 48e9efe

Browse files
committed
remove tests for undefined paths
R=arv BUG= Review URL: https://codereview.appspot.com/38630043
1 parent c141037 commit 48e9efe

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/observe.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@
665665
function PathObserver(object, path, callback, target, transformFn,
666666
setValueFn) {
667667
var path = path instanceof Path ? path : getPath(path);
668-
if (!path || !path.length || !isObject(object)) {
669-
this.value_ = path ? path.getValueFrom(object) : undefined;
668+
if (!path.valid || !path.length || !isObject(object)) {
669+
this.value_ = path.getValueFrom(object);
670670
this.value = transformFn ? transformFn(this.value_) : this.value_;
671671
this.closed_ = true;
672672
return;
@@ -768,7 +768,7 @@
768768
throw Error('Cannot add more paths once started.');
769769

770770
var path = path instanceof Path ? path : getPath(path);
771-
var value = path ? path.getValueFrom(object) : undefined;
771+
var value = path.getValueFrom(object);
772772

773773
this.observed_.push(object, path);
774774
this.values_.push(value);
@@ -787,8 +787,6 @@
787787
var anyChanged = false;
788788
for (var i = 0; i < this.observed_.length; i = i+2) {
789789
var path = this.observed_[i+1];
790-
if (!path)
791-
continue;
792790
var object = this.observed_[i];
793791
var value = path.getValueFrom(object, this.observedSet_);
794792
var oldValue = this.values_[i/2];

tests/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ suite('PathObserver Tests', function() {
267267

268268
teardown(doTeardown);
269269

270+
test('invalid', function() {
271+
var observer = new PathObserver({ a: { b: 1 }} , 'a b', callback);
272+
assert.strictEqual(undefined, observer.value);
273+
observer.deliver();
274+
assert.isFalse(callbackInvoked);
275+
});
276+
270277
test('Close Invokes Close', function() {
271278
var called = false;
272279
var obj = { foo: 1, close: function() { called = true }};

0 commit comments

Comments
 (0)