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

Try to modify it instance.slots.default The default method of, unexpected error #2877

Closed
1119879311 opened this issue Dec 24, 2020 · 2 comments

Comments

@1119879311
Copy link

Version

3.0.4

Reproduction link

http://192.168.3.5:8080/

Steps to reproduce

import {getCurrentInstance,defineComponent} from "vue"

const mapFilterChildCpt = (data,cptName,resArr=[])=>{
data.forEach(itme=>{
if(itme.type.name==cptName){
resArr.push(itme)
}else if(itme.shapeFlag==16){
resArr=[...resArr,...mapFilterChildCpt(itme.children||[],cptName)]
}
})
return resArr
}

export default defineComponent({

setup(){
let solt = instance.slots.default
instance.slots.default = ()=>{
let child = solt()
return mapFilterChildCpt(child,'by-carousel-item',[])
}

}

})

What is expected?

You can modify the default instance.slots.default To modify (filter) the specific components under the slot

What is actually happening?

[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug.
Uncaught (in promise) TypeError: Cannot read property 'parentNode' of null
at parentNode (runtime-dom.esm-bundler.js?830f:30)
at patchBlockChildren (runtime-core.esm-bundler.js?5c40:4009)
at processFragment (runtime-core.esm-bundler.js?5c40:4065)
at patch (runtime-core.esm-bundler.js?5c40:3708)
at patchBlockChildren (runtime-core.esm-bundler.js?5c40:4013)
at patchElement (runtime-core.esm-bundler.js?5c40:3977)
at processElement (runtime-core.esm-bundler.js?5c40:3795)
at patch (runtime-core.esm-bundler.js?5c40:3712)
at componentEffect (runtime-core.esm-bundler.js?5c40:4275)
at reactiveEffect (reactivity.esm-bundler.js?a1e9:42)

@edison1105
Copy link
Member

edison1105 commented Dec 24, 2020

maybe close by #2717, its not release yet.

@posva
Copy link
Member

posva commented Dec 24, 2020

It's maybe what @edison1105 said but you shouldn't manually modify the slots in an instance.
Also you should read https://new-issue.vuejs.org/?repo=vuejs/vue#why-repro

@posva posva closed this as completed Dec 24, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants