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

fix props & emits proto #2573

Closed
wants to merge 2 commits into from
Closed

Conversation

LongTengDao
Copy link
Contributor

@LongTengDao LongTengDao commented Nov 8, 2020

  1. props (main):

Any key in Object.prototype such as valueOf can not be a prop to receive currently.

Vue.createApp({
    template: '<MyComponent />',
    components: {
        MyComponent: {
            template: '<div>{{ valueOf }}<br>{{ toString }}</div>',
            props: {
                valueOf: { default: 'v' },
                toString: { },
            },
        },
    },
}).mount('body');

prop will get function value instead of undefined or default option.

  1. emits (incidental):

$emit("__defineGetter__") may cause bug.

@posva
Copy link
Member

posva commented Nov 9, 2020

I would say it's better not to be able to receive a prop that conflicts with existing properties en objects. As well as emitting an event named __defineGetter__ which is unrealistic in an application.

Having objects with the Object prototype benefit from methods like keys

@LongTengDao
Copy link
Contributor Author

doc said the only rule is not to use key start with _ or $, if this is intended and won't be fix, I think it will be good to write in doc and make a warn check in Vue, not treat it as if it not happen

@LongTengDao
Copy link
Contributor Author

the main problem won't happen in components, and the root component rarely has props, so this PR is not necessary.

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

Successfully merging this pull request may close these issues.

None yet

2 participants