Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4bca212
feat: Implemented new binding expression parser for NativeScript Core.
CatchABus Dec 31, 2021
b75be12
chore: Removed unused import.
CatchABus Dec 31, 2021
b756d34
fix: Wrong model parameter in MemberExpression parser.
CatchABus Dec 31, 2021
3bfc6bd
chore: Minor cleaning for `Identifier` parser.
CatchABus Dec 31, 2021
7affa1e
feat: Added support for template literals (non-tagged).
CatchABus Dec 31, 2021
5e3145c
feat: Added proper support for function context and computed properties.
CatchABus Dec 31, 2021
0399285
fix: Do not parse parent expressions until parent view is ready.
CatchABus Dec 31, 2021
2295aad
chore: Added two-way binding check to ensure expression is not parsed…
CatchABus Dec 31, 2021
91ac423
chore: Small refactor regarding expression value.
CatchABus Dec 31, 2021
842f701
chore: Added a `prettier` ignore to keep `in` and `instanceof` proper…
CatchABus Jan 1, 2022
0bfa368
chore: Added null coalescing operator inside schema of supported oper…
CatchABus Jan 1, 2022
4008d27
chore: Added prettier-ignore for expression parsers.
CatchABus Jan 2, 2022
745c04a
chore: Improved checks and added support for `void` and `typeof`.
CatchABus Jan 2, 2022
7b2c7c7
fix: Regex literal was not handled.
CatchABus Jan 2, 2022
71a1db7
chore: Added ts types.
CatchABus Jan 2, 2022
06965cc
chore: Added `ASTExpression` type.
CatchABus Jan 2, 2022
b4398a8
fix: Conditional and Logical expressions calculated `right` value whe…
CatchABus Jan 2, 2022
261c2a6
ref: Improved converters mechanism.
CatchABus Jan 2, 2022
7a338f0
fix: Coverters were broken on previous commit.
CatchABus Jan 2, 2022
3e17375
feat: Added support for optional chaining.
CatchABus Jan 3, 2022
4eaf0be
fix: Object expression did not parse keys properly if they contained …
CatchABus Jan 3, 2022
221c2c9
chore: Using `acorn` parser as it's used from NS webpack and supports…
CatchABus Jan 3, 2022
0c81055
fix: Non-computed properties were broken in the case of CallExpression.
CatchABus Jan 3, 2022
1eb31a1
chore: Improved computed property check in `MemberExpression`.
CatchABus Jan 3, 2022
191cae8
chore: Changed `acorn` ecma version since it's not supported by acorn…
CatchABus Jan 5, 2022
2f7627d
test: Corrected test regarding converters.
CatchABus Jan 5, 2022
9b3b0e5
test: More `converter` tests to correct.
CatchABus Jan 6, 2022
b56d6bd
fix: Corrected function call for broken test.
CatchABus Jan 6, 2022
8dfc7e9
fix: Expression parser was using a model copy that did not inherit Ob…
CatchABus Jan 6, 2022
8ff0d33
fix: Added missing case when computed properties are actually variables.
CatchABus Jan 6, 2022
eec8cd3
fix: Binding reactivity was broken for `$value` in previous updates.
CatchABus Jan 6, 2022
4953ac5
chore: Minor type correction.
CatchABus Jan 6, 2022
47aa17d
chore: Cleaning up AST checks.
CatchABus Jan 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions apps/automated/src/ui/core/bindable/bindable-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,19 @@ export function test_BindingConverterCalledEvenWithNullValue() {
const testPropertyValue = null;
const expectedValue = 'collapsed';
pageViewModel.set('testProperty', testPropertyValue);
appModule.getResources()['converter'] = function (value) {
if (value) {
return 'visible';
} else {
return 'collapsed';
}
appModule.getResources()['converter'] = {
toView: function (value) {
if (value) {
return 'visible';
} else {
return 'collapsed';
}
},
};

const testFunc = function (views: Array<View>) {
const testLabel = <Label>views[0];
testLabel.bind({ sourceProperty: 'testProperty', targetProperty: 'text', expression: 'testProperty | converter' });
testLabel.bind({ sourceProperty: 'testProperty', targetProperty: 'text', expression: 'testProperty | converter()' });

const page = <Page>views[1];
page.bindingContext = pageViewModel;
Expand Down
40 changes: 23 additions & 17 deletions apps/automated/src/ui/list-view/list-view-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,17 @@ export class ListViewTest extends UITest<ListView> {
public test_usingAppLevelConvertersInListViewItems() {
var listView = this.testView;

var dateConverter = function (value, format) {
var result = format;
var day = value.getDate();
result = result.replace('DD', day < 10 ? '0' + day : day);
var month = value.getMonth() + 1;
result = result.replace('MM', month < 10 ? '0' + month : month);
result = result.replace('YYYY', value.getFullYear());

return result;
var dateConverter = {
toView: function (value, format) {
var result = format;
var day = value.getDate();
result = result.replace('DD', day < 10 ? '0' + day : day);
var month = value.getMonth() + 1;
result = result.replace('MM', month < 10 ? '0' + month : month);
result = result.replace('YYYY', value.getFullYear());

return result;
},
};

Application.getResources()['dateConverter'] = dateConverter;
Expand Down Expand Up @@ -565,10 +567,12 @@ export class ListViewTest extends UITest<ListView> {
var listView = this.testView;
var converterCalledCounter = 0;

var testConverter = function (value) {
converterCalledCounter++;
var testConverter = {
toView: function (value) {
converterCalledCounter++;

return value;
return value;
},
};

Application.getResources()['testConverter'] = testConverter;
Expand All @@ -578,7 +582,7 @@ export class ListViewTest extends UITest<ListView> {
listView.bindingContext = listViewModel;

listView.bind({ sourceProperty: 'items', targetProperty: 'items' });
listView.itemTemplate = '<Label id="testLabel" text="{{ $value, $value | testConverter }}" />';
listView.itemTemplate = '<Label id="testLabel" text="{{ $value, $value | testConverter() }}" />';

this.waitUntilListViewReady();

Expand All @@ -589,10 +593,12 @@ export class ListViewTest extends UITest<ListView> {
var listView = this.testView;
var converterCalledCounter = 0;

var testConverter = function (value) {
converterCalledCounter++;
var testConverter = {
toView: function (value) {
converterCalledCounter++;

return value;
return value;
},
};

Application.getResources()['testConverter'] = testConverter;
Expand All @@ -602,7 +608,7 @@ export class ListViewTest extends UITest<ListView> {
listView.bindingContext = listViewModel;

listView.bind({ sourceProperty: 'items', targetProperty: 'items' });
listView.itemTemplate = '<StackLayout><Label id="testLabel" text="{{ $value, $value | testConverter }}" /></StackLayout>';
listView.itemTemplate = '<StackLayout><Label id="testLabel" text="{{ $value, $value | testConverter() }}" /></StackLayout>';

this.waitUntilListViewReady();

Expand Down
22 changes: 12 additions & 10 deletions apps/automated/src/ui/repeater/repeater-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,17 @@ export function test_splice_observable_array_refreshes_the_Repeater() {
export function test_usingAppLevelConvertersInRepeaterItems() {
var repeater = new Repeater();

var dateConverter = function (value, format) {
var result = format;
var day = value.getDate();
result = result.replace('DD', month < 10 ? '0' + day : day);
var month = value.getMonth() + 1;
result = result.replace('MM', month < 10 ? '0' + month : month);
result = result.replace('YYYY', value.getFullYear());

return result;
var dateConverter = {
toView: function (value, format) {
var result = format;
var day = value.getDate();
result = result.replace('DD', month < 10 ? '0' + day : day);
var month = value.getMonth() + 1;
result = result.replace('MM', month < 10 ? '0' + month : month);
result = result.replace('YYYY', value.getFullYear());

return result;
},
};

Application.getResources()['dateConverter'] = dateConverter;
Expand All @@ -275,7 +277,7 @@ export function test_usingAppLevelConvertersInRepeaterItems() {

TKUnit.waitUntilReady(() => repeater.isLayoutValid);

TKUnit.assertEqual(getChildAtText(repeater, 0), dateConverter(new Date(), 'DD.MM.YYYY'), 'element');
TKUnit.assertEqual(getChildAtText(repeater, 0), dateConverter.toView(new Date(), 'DD.MM.YYYY'), 'element');
}

helper.buildUIAndRunTest(repeater, testAction);
Expand Down
19 changes: 0 additions & 19 deletions packages/core/js-libs/esprima/LICENSE.BSD

This file was deleted.

24 changes: 0 additions & 24 deletions packages/core/js-libs/esprima/README.md

This file was deleted.

Loading