Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(factory): improve fallback multiple v-if #11857

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You are looking at the repository for Vue 2. The repo for Vue 3 is [vuejs/core](
Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome [backers](https://github.com/vuejs/core/blob/main/BACKERS.md). If you'd like to join them, please consider [ sponsor Vue's development](https://vuejs.org/sponsor/).

<p align="center">
<a target="_blank" href="https://vuejs.org/sponsor/">
<a target="_blank" href="https://vuejs.org/sponsor/#current-sponsors">
<img alt="sponsors" src="https://sponsors.vuejs.org/sponsors.svg">
</a>
</p>
Expand Down
4 changes: 2 additions & 2 deletions examples/todomvc/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var app = new Vue({
},

// computed properties
// https://vuejs.org/guide/computed.html
// https://v2.vuejs.org/v2/guide/computed.html
computed: {
filteredTodos: function () {
return filters[this.visibility](this.todos)
Expand Down Expand Up @@ -129,7 +129,7 @@ var app = new Vue({

// a custom directive to wait for the DOM to be updated
// before focusing on the input field.
// https://vuejs.org/guide/custom-directive.html
// https://v2.vuejs.org/v2/guide/custom-directive.html
directives: {
'todo-focus': function (el, binding) {
if (binding.value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-server-renderer/build.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5157,7 +5157,7 @@ function genFor (
state.warn(
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
"v-for should have explicit keys. " +
"See https://vuejs.org/guide/list.html#key for more info.",
"See https://v2.vuejs.org/v2/guide/list.html#Maintaining-State for more info.",
el.rawAttrsMap['v-for'],
true /* tip */
);
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-template-compiler/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4444,7 +4444,7 @@
state.warn(
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
"v-for should have explicit keys. " +
"See https://vuejs.org/guide/list.html#key for more info.",
"See https://v2.vuejs.org/v2/guide/list.html#Maintaining-State for more info.",
el.rawAttrsMap['v-for'],
true /* tip */
);
Expand Down
2 changes: 1 addition & 1 deletion packages/weex-template-compiler/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3489,7 +3489,7 @@ function genFor (
state.warn(
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
"v-for should have explicit keys. " +
"See https://vuejs.org/guide/list.html#key for more info.",
"See https://v2.vuejs.org/v2/guide/list.html#Maintaining-State for more info.",
el.rawAttrsMap['v-for'],
true /* tip */
);
Expand Down
6 changes: 3 additions & 3 deletions packages/weex-vue-framework/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ if (process.env.NODE_ENV !== 'production') {
'referenced during render. Make sure that this property is reactive, ' +
'either in the data option, or for class-based components, by ' +
'initializing the property. ' +
'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties',
target
);
};
Expand All @@ -2020,7 +2020,7 @@ if (process.env.NODE_ENV !== 'production') {
"Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
'prevent conflicts with Vue internals. ' +
'See: https://vuejs.org/v2/api/#data',
'See: https://v2.vuejs.org/v2/api/#data',
target
);
};
Expand Down Expand Up @@ -4900,7 +4900,7 @@ function initData (vm) {
data = {};
process.env.NODE_ENV !== 'production' && warn(
'data functions should return an object:\n' +
'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
vm
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function genFor (
state.warn(
`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
`v-for should have explicit keys. ` +
`See https://vuejs.org/guide/list.html#key for more info.`,
`See https://v2.vuejs.org/v2/guide/list.html#Maintaining-State for more info.`,
el.rawAttrsMap['v-for'],
true /* tip */
)
Expand Down
4 changes: 2 additions & 2 deletions src/core/instance/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (process.env.NODE_ENV !== 'production') {
'referenced during render. Make sure that this property is reactive, ' +
'either in the data option, or for class-based components, by ' +
'initializing the property. ' +
'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties',
target
)
}
Expand All @@ -29,7 +29,7 @@ if (process.env.NODE_ENV !== 'production') {
`Property "${key}" must be accessed with "$data.${key}" because ` +
'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
'prevent conflicts with Vue internals. ' +
'See: https://vuejs.org/v2/api/#data',
'See: https://v2.vuejs.org/v2/api/#data',
target
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/instance/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function initData (vm: Component) {
data = {}
process.env.NODE_ENV !== 'production' && warn(
'data functions should return an object:\n' +
'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
vm
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/vdom/helpers/normalize-scoped-slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function normalizeScopedSlot(normalSlots, key, fn) {
let vnode: ?VNode = res && res[0]
return res && (
!vnode ||
(res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
(res.every(r => r.isComment) && !isAsyncPlaceholder(vnode)) // #9658, #10391, #11856
) ? undefined
: res
}
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/web/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (inBrowser) {
console[console.info ? 'info' : 'log'](
`You are running Vue in development mode.\n` +
`Make sure to turn on production mode when deploying for production.\n` +
`See more tips at https://vuejs.org/guide/deployment.html`
`See more tips at https://v2.vuejs.org/v2/guide/deployment.html`
)
}
}, 0)
Expand Down
13 changes: 13 additions & 0 deletions test/unit/features/component/component-scoped-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,19 @@ describe('Component scoped slot', () => {
expect(vm.$el.textContent).toMatch('fallback')
})

//#11856
it('fallback for scoped slot with multiple v-if', () => {
const vm = new Vue({
template: `<test><template v-if="0 === 1">hi</template><template v-if="1 === 0">hi2</template></test>`,
components: {
Test: {
template: `<div><slot>fallback</slot></div>`
}
}
}).$mount()
expect(vm.$el.textContent).toEqual('fallback')
})

// #9699
// Component only has normal slots, but is passing down $scopedSlots directly
// $scopedSlots should not be marked as stable in this case
Expand Down