mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #921 from NativeScript/nnikolov/PropertyAccessorsThreatedAsExpressions
Fixed index property accessors are treated as expressions.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
// regex that contains all symbols applicable for expression used to AI detect an expression.
|
// regex that contains all symbols applicable for expression used to AI detect an expression.
|
||||||
var expressionSymbolsRegex = /[ \+\-\*%\?:<>=!\|&\(\)\[\]^~]/;
|
var expressionSymbolsRegex = /[\+\-\*\/%\?:<>=!\|&\(\)^~]/;
|
||||||
|
|
||||||
export module bindingConstants {
|
export module bindingConstants {
|
||||||
export var sourceProperty = "sourceProperty";
|
export var sourceProperty = "sourceProperty";
|
||||||
|
@ -195,8 +195,27 @@ export class Binding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static getProperties(property: string): Array<string> {
|
private static getProperties(property: string): Array<string> {
|
||||||
|
var result: Array<string>;
|
||||||
if (property) {
|
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 {
|
else {
|
||||||
return [];
|
return [];
|
||||||
|
Reference in New Issue
Block a user