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

Commit 9552ec3

Browse files
author
John Messerly
committed
prevent incorrect codegen with empty path string
fixes googlearchive/polymer-expressions#42 investigation notes here: googlearchive/polymer-expressions#42 (comment) it didn't look to me like isIndex was called on a hot path, so I just added a guard against empty string. Let me know if there's a smarter way to do that check. [email protected] Review URL: https://codereview.appspot.com/136950043
1 parent 1ca7298 commit 9552ec3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/observe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
var hasEval = detectEval();
8686

8787
function isIndex(s) {
88-
return +s === s >>> 0;
88+
return +s === s >>> 0 && s !== '';
8989
}
9090

9191
function toNumber(s) {

tests/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ suite('Path', function() {
156156
assertPath('foo["b\\"az"]', ['foo', 'b"az'], 'foo["b\\"az"]');
157157
assertPath("foo['b\\'az']", ['foo', "b'az"], 'foo["b\'az"]');
158158
assertPath(['a', 'b'], ['a', 'b'], 'a.b');
159+
assertPath([''], [''], '[""]');
159160

160161
function Foo(val) { this.val = val; }
161162
Foo.prototype.toString = function() { return 'Foo' + this.val; };

0 commit comments

Comments
 (0)