Skip to content

Commit 97e8dad

Browse files
authored
refactor(ref): deprecate view-model.ref and introduce component.ref (#1803)
* chore(deps): upgrade ts to 5.1.6 [skip ci]
1 parent bf1ca4c commit 97e8dad

File tree

76 files changed

+1368
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1368
-635
lines changed

docs/user-docs/developer-guides/cheat-sheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ export class BananaInBox {
454454
<form submit.trigger="$event.preventDefault()">
455455
<!-- Set this html element to the 'nameInput' property on the declaring component -->
456456
<input ref="nameInput">
457-
<!-- Set the view model of this <my-component> custom element
457+
<!-- Set the component instance of this <my-component> custom element
458458
to the 'myComponentViewModel' property on the declaring component -->
459-
<my-component view-model.ref="myComponentViewModel">
459+
<my-component component.ref="myComponentViewModel">
460460
<!-- Automatic two-way binding to an input (convention, equivalent to value.two-way) -->
461461
<input value.bind="name">
462462
<!-- Manual two-way binding to an input -->

docs/user-docs/developer-guides/migrating-to-aurelia-2/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ interface IAurelia {
5959

6060
Parent container and resources can be specified through this config.
6161

62+
### View model ref binding (view-model.ref="...")
63+
64+
In v2, in order to get a reference to the underlying component view model, use `component.ref` instead of view-model.ref
65+
This is to make terminologies consistent as we are moving towards component oriented terms.
66+
6267
### Call binding (some-prop.call="...")
6368

6469
The call binding no longer assigns properties of the first argument pass to the call to the calling override context. This is unreasonably dynamic and could result in hard-to-understand templates.
@@ -135,7 +140,7 @@ Change it to:
135140
```
136141

137142
- In Aurelia 2, all bindings are passed through to the underlying custom element
138-
composition, so `view-model.ref` no longer means getting a reference to the composer, but the composed view model instead.
143+
composition, so `component.ref` (`view-model.ref` in v1) no longer means getting a reference to the composer, but the composed view model instead.
139144

140145
Read more about dynamic composition in v2 in this [dynamic composition doc](../../getting-to-know-aurelia/dynamic-composition.md) and [dynamic ui composition doc](../../app-basics/dynamic-ui-composition.md).
141146

docs/user-docs/developer-guides/migrating-to-aurelia-2/side-by-side-comparison.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,13 @@ export class MyApp {
533533
| one-time | **** | |
534534
| bind | **** | |
535535

536-
### Referencing DOM Elements
536+
### References
537537

538-
| Name | Aurelia 1 & 2 | Description |
539-
| ---- | ------------- | ----------- |
540-
| ref | **** | |
541-
| view-model.ref | **** | |
538+
| Name | Aurelia 1 | Aurelia 2 | Description |
539+
| ---- | - | - |
540+
| ref | **** | **** | |
541+
| view-model.ref | **** | **** | deprecated in v2 |
542+
| component.ref | **** | **** | Not in v1 |
542543

543544
### Passing Function References
544545

docs/user-docs/getting-to-know-aurelia/dynamic-composition.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ export class MyComponent {
8383

8484
## Accessing the view model
8585

86-
In some scenarios, you may want to access the view model of the component being rendered using `<au-compose>` we can achieve this by adding the `view-model.ref` binding to our compose element.
86+
In some scenarios, you may want to access the view model of the component being rendered using `<au-compose>` we can achieve this by adding the `component.ref`(known as `view-model.ref` in v1) binding to our compose element.
8787

8888
```html
89-
<au-compose view-model.ref="myCompose"></au-compose>
89+
<au-compose component.ref="myCompose"></au-compose>
9090
```
9191

92-
This will work as though it were a `view-model.ref` binding on a standard custom element.
92+
This will work as though it were a `component.ref` binding on a standard custom element.
9393

9494
## Passing props through
9595

@@ -155,7 +155,7 @@ If you still want a view supporting a dynamically loaded module, you can create
155155

156156
The above value converter will load the URL and return the text response. For view models, something similar can be achieved where an object or class can be returned.
157157

158-
3. In Aurelia 2, all bindings are transferred to the underlying custom element composition. Therefore, `view-model.ref` no longer signifies obtaining a reference to the composer, but rather to the composed view model.
158+
3. In Aurelia 2, all bindings are transferred to the underlying custom element composition. Therefore, `component.ref` no longer signifies obtaining a reference to the composer, but rather to the composed view model.
159159
### Scope breaking changes
160160

161161
By default, when composing, the outer scope will not be inherited. The parent scope will only be inherited when it is not a custom element being composed. This means the outer scope will be used when composing only a view or plain object as the view model.

docs/user-docs/templates/template-syntax.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ export class MyApp {
298298

299299
The `ref` attribute has several qualifiers you can use in conjunction with custom elements and attributes:
300300

301-
* `view-model.ref="expression"`: create a reference to a custom element's view-model
302-
* `custom-attribute.ref="expression"`: create a reference to a custom attribute's view-model
303-
* `controller.ref="expression"`: create a reference to a custom element's controller instance
301+
* `component.ref="expression"`: create a reference to a custom element's component instance(view-model). This is known as `view-model.ref` in v1.
302+
* `custom-attribute.ref="expression"`: create a reference to a custom attribute's component instance (view-model).
303+
* `controller.ref="expression"`: create a reference to a custom element's controller instance.
304304

305305
{% hint style="info" %}
306306
Template references are a great way to reference elements inside view models for use with third-party libraries. They negate the need to query for elements using Javascript APIs.

examples/base-url/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"rimraf": "^3.0.2",
2929
"style-loader": "^3.3.1",
3030
"ts-loader": "^9.3.0",
31-
"typescript": "5.0.2",
31+
"typescript": "5.1.6",
3232
"url-loader": "^4.1.1",
3333
"webpack": "^5.72.0",
3434
"webpack-bundle-analyzer": "^4.5.0",

examples/doc-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rimraf": "^3.0.0",
2525
"style-loader": "^3.3.1",
2626
"ts-loader": "^9.3.0",
27-
"typescript": "5.0.2",
27+
"typescript": "5.1.6",
2828
"webpack": "^5.72.0",
2929
"webpack-cli": "^4.9.2",
3030
"webpack-dev-server": "^4.8.1"

examples/jit-webpack-conventions-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
"@aurelia/webpack-loader": "dev",
3232
"ts-loader": "^9.3.0",
3333
"@types/node": "^14.18.14",
34-
"typescript": "5.0.2"
34+
"typescript": "5.1.6"
3535
}
3636
}

examples/jit-webpack-vanilla-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"html-webpack-plugin": "^5.5.0",
3030
"rimraf": "^3.0.0",
3131
"ts-loader": "^9.3.0",
32-
"typescript": "5.0.2",
32+
"typescript": "5.1.6",
3333
"webpack-cli": "^4.9.2",
3434
"webpack": "^5.72.0"
3535
}

examples/lazy-loading-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"rimraf": "^3.0.2",
2929
"style-loader": "^3.3.1",
3030
"ts-loader": "^9.3.0",
31-
"typescript": "5.0.2",
31+
"typescript": "5.1.6",
3232
"url-loader": "^4.1.1",
3333
"webpack": "^5.72.0",
3434
"webpack-bundle-analyzer": "^4.5.0",

examples/navigation-skeleton/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"rimraf": "^3.0.0",
3333
"style-loader": "^3.3.1",
3434
"ts-loader": "^9.3.0",
35-
"typescript": "5.0.2",
35+
"typescript": "5.1.6",
3636
"url-loader": "^4.1.1",
3737
"webpack": "^5.72.0",
3838
"webpack-cli": "^4.9.2",

examples/realworld-advanced/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rimraf": "^3.0.0",
2525
"style-loader": "^3.3.1",
2626
"ts-loader": "^9.3.0",
27-
"typescript": "5.0.2",
27+
"typescript": "5.1.6",
2828
"webpack": "^5.72.0",
2929
"webpack-cli": "^4.9.2",
3030
"webpack-dev-server": "^4.8.1"

examples/realworld-conventions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rimraf": "^3.0.0",
2525
"style-loader": "^3.3.1",
2626
"ts-loader": "^9.3.0",
27-
"typescript": "5.0.2",
27+
"typescript": "5.1.6",
2828
"webpack": "^5.72.0",
2929
"webpack-cli": "^4.9.2",
3030
"webpack-dev-server": "^4.8.1"

examples/realworld/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rimraf": "^3.0.0",
2525
"style-loader": "^3.3.1",
2626
"ts-loader": "^9.3.0",
27-
"typescript": "5.0.2",
27+
"typescript": "5.1.6",
2828
"webpack": "^5.72.0",
2929
"webpack-cli": "^4.9.2",
3030
"webpack-dev-server": "^4.8.1"

examples/router-animation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@
4141
"webpack-bundle-analyzer": "^4.5.0",
4242
"html-webpack-plugin": "^5.5.0",
4343
"ts-loader": "^9.3.0",
44-
"typescript": "5.0.2"
44+
"typescript": "5.1.6"
4545
}
4646
}

examples/validation-with-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"html-webpack-plugin": "^5.5.0",
2424
"rimraf": "^3.0.0",
2525
"ts-loader": "^9.3.0",
26-
"typescript": "5.0.2",
26+
"typescript": "5.1.6",
2727
"webpack": "^5.72.0",
2828
"webpack-cli": "^4.9.2",
2929
"webpack-dev-server": "^4.8.1"

0 commit comments

Comments
 (0)