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

Implement v-on and v-bind #63

Merged
merged 2 commits into from Apr 28, 2022

Conversation

DavidBerger98
Copy link
Contributor

v-on and v-bind were not mapped from python keys to vue keys, which made it not possible to implement and example like this:

with vuetify.VMenu():
    with vuetify.Template(v_slot_activator="{ on, attrs }"):
        with vuetify.VBtn(icon=True, v_bind="attrs", v_on="on", v_on_click="test"):
            vuetify.VIcon("mdi-dots-vertical")
    with vuetify.VList(), vuetify.VListItem(
        v_for="(item, i) in menu_items",
        key="i",
        value=["item"],
    ):
        vuetify.VBtn(
            "{{ item }}",
            click=(print_item, "[item]"),
        )

Note: The list of v_on_names does not cover all possibilities yet. Since you can chain most of the keywords in different ways, we should probably build the list programmatically. (e.g. v-on:click.self.stop.prevent etc.)

@DavidBerger98
Copy link
Contributor Author

DavidBerger98 commented Apr 27, 2022

@jourdain While we're at the topic of self._attr_names, wouldn't it be more efficient to have them as a class variable rather than instance variable? Subclasses of AbstractElement could then add new attr_names with __init_subclass__ (https://peps.python.org/pep-0487/). It is only supported for Python>=3.6, however seeing that support for Python 3.5 has been dropped, we may make use of that method.

I can create an issue for that and start working on it, but thought I would ask you first. WDYT?

@jourdain
Copy link
Collaborator

jourdain commented Apr 27, 2022

I'm not sure I agree as not all HtmlElements are equals and they don't have the same set of available attributes. Moreover, if you have a unique list, you start having more chance of conflict between attributes and events.

Finally, for any advance usecase, you can provide the list of attributes/events to process for a given instance. So even if the default are missing something, you can still make it work.

@jourdain
Copy link
Collaborator

But I'm fine merging your current changes.

@DavidBerger98
Copy link
Contributor Author

I'm not sure I agree as not all HtmlElements are equals and they don't have the same set of available attributes. Moreover, if you have a unique list, you start having more chance of conflict between attributes and events.

Finally, for any advance usecase, you can provide the list of attributes/events to process for a given instance. So even if the default are missing something, you can still make it work.

I see! I thought that _attr_names is a read-only list of available attributes for that type of HTML element.

But then nvm, thank you for the clarification!

@jourdain jourdain merged commit b3cbe5e into Kitware:master Apr 28, 2022
@jourdain
Copy link
Collaborator

🎉 This PR is included in version 1.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants