Skip to content

Commit 657f5bf

Browse files
committed
Merge branch 'master' into rc
2 parents 56332c1 + 58d8d9a commit 657f5bf

File tree

7 files changed

+60
-71
lines changed

7 files changed

+60
-71
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
name: Build & Test
22

3-
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- master
3+
on: [push, pull_request]
104

115
jobs:
126
build:
@@ -31,4 +25,3 @@ jobs:
3125
run: yarn test-unit
3226
env:
3327
CI: true
34-

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="0.6.6"></a>
2+
## [0.6.6](https://github.com/vuejs/composition-api/compare/v0.6.5...v0.6.6) (2020-06-21)
3+
4+
5+
### Reverts
6+
7+
* [#387](https://github.com/vuejs/composition-api/issues/387) ([#395](https://github.com/vuejs/composition-api/issues/395)) ([b9fab71](https://github.com/vuejs/composition-api/commit/b9fab71))
8+
9+
10+
111
<a name="0.6.5"></a>
212
## [0.6.5](https://github.com/vuejs/composition-api/compare/v0.6.4...v0.6.5) (2020-06-19)
313

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-present, liximomo(X.L)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ declare module '@vue/composition-api' {
294294
</details>
295295

296296

297+
### :x: Reactive APIs in `data()`
298+
299+
Passing `ref`, `reactive` or other reactive apis to `data()` would not work.
300+
301+
```jsx
302+
export default {
303+
data() {
304+
return {
305+
// will result { a: { value: 1 } } in template
306+
a: ref(1)
307+
}
308+
},
309+
};
310+
```
311+
297312
## SSR
298313

299314
Even if there is no definitive Vue 3 API for SSR yet, this plugin implements the `onServerPrefetch` lifecycle hook that allows you to use the `serverPrefetch` hook found in the classic API.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/composition-api",
3-
"version": "0.6.5",
3+
"version": "0.6.6",
44
"description": "Provide logic composition capabilities for Vue.",
55
"keywords": [
66
"vue",

src/setup.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,6 @@ export function mixin(Vue: VueConstructor) {
154154
}
155155
}
156156

157-
const { data } = $options
158-
// wrapper the data option, so we can invoke setup before data get resolved
159-
$options.data = function wrappedData() {
160-
if (setup) {
161-
initSetup(vm, vm.$props)
162-
}
163-
const dataValue =
164-
typeof data === 'function'
165-
? (data as (
166-
this: ComponentInstance,
167-
x: ComponentInstance
168-
) => object).call(vm, vm)
169-
: data || {}
170-
return unwrapRefProxy(dataValue)
171-
}
172-
173157
if (!setup) {
174158
return
175159
}
@@ -182,6 +166,18 @@ export function mixin(Vue: VueConstructor) {
182166
}
183167
return
184168
}
169+
170+
const { data } = $options
171+
// wrapper the data option, so we can invoke setup before data get resolved
172+
$options.data = function wrappedData() {
173+
initSetup(vm, vm.$props)
174+
return typeof data === 'function'
175+
? (data as (
176+
this: ComponentInstance,
177+
x: ComponentInstance
178+
) => object).call(vm, vm)
179+
: data || {}
180+
}
185181
}
186182

187183
function initSetup(vm: ComponentInstance, props: Record<any, any> = {}) {

test/setup.spec.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ describe('setup', () => {
8484
expect(vm.b).toBe(1)
8585
})
8686

87-
// #385
88-
it('should unwrapRef on data', () => {
89-
const vm = new Vue({
90-
data() {
91-
return {
92-
a: ref(1),
93-
}
94-
},
95-
setup() {},
96-
}).$mount()
97-
expect(vm.a).toBe(1)
98-
})
99-
10087
it('should work with `methods` and `data` options', (done) => {
10188
let calls = 0
10289
const vm = new Vue({
@@ -769,37 +756,4 @@ describe('setup', () => {
769756
const vm = new Vue(Constructor).$mount()
770757
expect(vm.$el.textContent).toBe('Composition-api')
771758
})
772-
773-
it('should keep data reactive', async () => {
774-
const vm = new Vue({
775-
template: `<div>
776-
<button id="a" @click="a++">{{a}}</button>
777-
<button id="b" @click="b++">{{b}}</button>
778-
</div>`,
779-
data() {
780-
return {
781-
a: 1,
782-
b: ref(1),
783-
}
784-
},
785-
}).$mount()
786-
787-
const a = vm.$el.querySelector('#a')
788-
const b = vm.$el.querySelector('#b')
789-
790-
expect(a.textContent).toBe('1')
791-
expect(b.textContent).toBe('1')
792-
793-
a.click()
794-
await Vue.nextTick()
795-
796-
expect(a.textContent).toBe('2')
797-
expect(b.textContent).toBe('1')
798-
799-
b.click()
800-
await Vue.nextTick()
801-
802-
expect(a.textContent).toBe('2')
803-
expect(b.textContent).toBe('2')
804-
})
805759
})

0 commit comments

Comments
 (0)