From d6e0a2b598d33bdaff78ab287e827e4828056b6d Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Mon, 12 Oct 2015 14:47:58 +0300 Subject: [PATCH] Fixed index property accessors are treated as expressions. --- ui/builder/binding-builder.ts | 2 +- ui/core/bindable.ts | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ui/builder/binding-builder.ts b/ui/builder/binding-builder.ts index 8e8afa2b7..dfbf13dd4 100644 --- a/ui/builder/binding-builder.ts +++ b/ui/builder/binding-builder.ts @@ -1,5 +1,5 @@ // regex that contains all symbols applicable for expression used to AI detect an expression. -var expressionSymbolsRegex = /[ \+\-\*%\?:<>=!\|&\(\)\[\]^~]/; +var expressionSymbolsRegex = /[\+\-\*\/%\?:<>=!\|&\(\)^~]/; export module bindingConstants { export var sourceProperty = "sourceProperty"; diff --git a/ui/core/bindable.ts b/ui/core/bindable.ts index d388581f1..d2d0727e4 100644 --- a/ui/core/bindable.ts +++ b/ui/core/bindable.ts @@ -195,8 +195,27 @@ export class Binding { } private static getProperties(property: string): Array { + var result: Array; if (property) { - return property.split("."); + // first replace all '$parents[..]' with a safe string + // second removes all ] since they are not important for property access and not needed + // then split properties either on '.' or '[' + var parentsMatches = property.match(bindingBuilder.parentsRegex); + result = property.replace(bindingBuilder.parentsRegex, "parentsMatch") + .replace(/\]/g, "") + .split(/\.|\[/); + + var i; + var resultLength = result.length; + var parentsMatchesCounter = 0; + for (i = 0; i < resultLength; i++) { + if (result[i] === "parentsMatch") { + result[i] = parentsMatches[parentsMatchesCounter]; + parentsMatchesCounter++; + } + } + + return result; } else { return [];