Skip to content

Commit 07b4dda

Browse files
fixed issue with square brackets in computed params (#13)
1 parent e65d827 commit 07b4dda

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

CHANGELOG.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to the "@qavajs/memory" will be documented in this file.
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
## [1.4.1]
8+
- :beetle: fixed issue with square brackets in computed params
9+
710
## [1.4.0]
811
- :rocket: added _parallel_ util function
912

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qavajs/memory",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "memory package for @qavajs framework",
55
"main": "index.js",
66
"scripts": {

src/Memory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ class Memory {
118118
if (char === '.' && !insideSquareBracket && !insideParenthesis) {
119119
tokens.push(currentToken);
120120
currentToken = '';
121-
} else if (char === '[') {
121+
} else if (char === '[' && !insideParenthesis) {
122122
insideSquareBracket = true;
123123
tokens.push(currentToken);
124124
currentToken = '';
125-
} else if (char === ']' && insideSquareBracket) {
125+
} else if (char === ']' && !insideParenthesis && insideSquareBracket) {
126126
insideSquareBracket = false;
127127
tokens.push(currentToken);
128128
currentToken = '';

tests/memory.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,30 @@ test('empty string', () => {
242242
expect(memory.getValue('$fn("")')).to.equal('');
243243
expect(memory.getValue("$fn('')")).to.equal('');
244244
});
245+
246+
test('param is property array element', () => {
247+
memory.setValue('obj1', {
248+
method1(val) {
249+
return val
250+
}
251+
})
252+
memory.setValue('obj2', {
253+
arr: [1, 42]
254+
})
255+
expect(memory.getValue('$obj1.method1($obj2.arr[1])')).to.equal(42);
256+
});
257+
258+
test('param is space containing property', () => {
259+
memory.setValue('obj1', {
260+
method1(val) {
261+
return val
262+
}
263+
})
264+
memory.setValue('obj2', {
265+
obj: {
266+
"contain space": 42
267+
}
268+
})
269+
expect(memory.getValue('$obj1.method1($obj2.obj["contain space"])')).to.equal(42);
270+
});
271+

0 commit comments

Comments
 (0)