alpinejs / alpine

A rugged, minimal framework for composing JavaScript behavior in your markup.
https://alpinejs.dev
MIT License
27.92k stars 1.22k forks source link

[CSP] Add support for nested properties to CSP build #4238

Closed SimoTod closed 3 months ago

SimoTod commented 3 months ago

This PR adds a minimal enhancement to the CSP build to support nested properties via dot notation (property accessor).

<div x-data="counter">
    <button @click="foo.increment">Increment</button>
    <span x-text="foo.count"></span>
</div>
Alpine.data('counter', () => ({
    foo: {
        count: 1,

        increment() {
            this.count++
        },
    },
}))

The build size is pretty much the same and it seems a reasonable change otherwise dev using the csp build are forced to flatten the component and put all properties at the top.

I only know about one user mentioning it though so feel free to close it if you think it's not worth it for now.

calebporzio commented 3 months ago

This is great. Thanks Simone!