diff --git a/editor/js/ui/common/typedInput.js b/editor/js/ui/common/typedInput.js index 90749d509..2bfea5e18 100644 --- a/editor/js/ui/common/typedInput.js +++ b/editor/js/ui/common/typedInput.js @@ -36,7 +36,7 @@ return false; } // Next char is a-z - if (!/[a-z0-9]/i.test(str[i+1])) { + if (!/[a-z0-9\$\_]/i.test(str[i+1])) { return false; } start = i+1; diff --git a/red/runtime/util.js b/red/runtime/util.js index f132564c8..cae03a4be 100644 --- a/red/runtime/util.js +++ b/red/runtime/util.js @@ -161,7 +161,7 @@ function normalisePropertyExpression(str) { throw new Error("Invalid property expression: unterminated expression"); } // Next char is a-z - if (!/[a-z0-9]/i.test(str[i+1])) { + if (!/[a-z0-9\$\_]/i.test(str[i+1])) { throw new Error("Invalid property expression: unexpected "+str[i+1]+" at position "+(i+1)); } start = i+1; diff --git a/test/red/runtime/util_spec.js b/test/red/runtime/util_spec.js index aa8e25728..9a4dbe37c 100644 --- a/test/red/runtime/util_spec.js +++ b/test/red/runtime/util_spec.js @@ -333,6 +333,11 @@ describe("red/util", function() { it("pass a['a.b[0]'].c",function() { testABC("a['a.b[0]'].c",['a','a.b[0]','c']); }) it("pass a[0][0][0]",function() { testABC("a[0][0][0]",['a',0,0,0]); }) + it('pass a.$b.c',function() { testABC('a.$b.c',['a','$b','c']); }) + it('pass a["$b"].c',function() { testABC('a["$b"].c',['a','$b','c']); }) + it('pass a._b.c',function() { testABC('a._b.c',['a','_b','c']); }) + it('pass a["_b"].c',function() { testABC('a["_b"].c',['a','_b','c']); }) + it("fail a'b'.c",function() { testInvalid("a'b'.c"); }) it("fail a['b'.c",function() { testInvalid("a['b'.c"); }) it("fail a[]",function() { testInvalid("a[]"); })