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

Remove every error reporting/debugging of provide/inject, or allow require flag for inject #6137

Closed
erwinQiu opened this issue Jul 17, 2017 · 3 comments

Comments

@erwinQiu
Copy link

What problem does this feature solve?

#5628

I found that vue checks all the inject value and throw a warn when development and null. I think it's not reasonable, here is the case:

we use provide/inject mixin to maintain the z-index for some popper component.
In our standard, z-index of tip is 100, dialog is 2000. Without the mixin, it's difficult to maintain the z-index when a tip in a dialog. With the provide/inject mixin, the tip in a dialog, the index will be 2001 while we do nothing extra in css.

In this case, the inject 'zIndexBase' is not necessary. the first popper component just use it's own zIndex. But in latest vue, it throw a warn.......

export default {
    provide() {
        return {
            zIndexBase: this.calcZIndex
        };
    },
    inject: ['zIndexBase'],
    props: {
        zIndex: {
            type: Number,
            default: 0
        }
    },
    computed: {
        calcZIndex() {
            if (!this.zIndexBase) {
                return this.zIndex;
            }
            return this.zIndexBase   this.zIndex / 100;
        },
        calcStyle() {
            return {
                zIndex: this.calcZIndex
            };
        }
    }

};

What does the proposed API look like?

the inject value can accept an object:

[{'key': 'keyItem', 'required': true}, 'zIncdexBase']

@jkzing
Copy link
Member

jkzing commented Jul 17, 2017

There is also a request ask for default injections (#6097), maybe we could consider them together.

@posva
Copy link
Member

posva commented Jul 17, 2017

Can you showcase the problem on a minimal jsfiddle?
To me it looks ilke you're looking for default values, so, as @jkzing said, I'll keep the other issue opened instead

@erwinQiu
Copy link
Author

Yes, this issue can be considered with #6097 together. Our purpose is to avoid the warning for missing inject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants