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

Disallow multiple w-bind in a single template #95

Open
maberer opened this issue Sep 22, 2015 · 1 comment
Open

Disallow multiple w-bind in a single template #95

maberer opened this issue Sep 22, 2015 · 1 comment

Comments

@maberer
Copy link
Contributor

maberer commented Sep 22, 2015

We should break compiling a template if it contains more than 1 w-bind attribute.
There is probably no good reason (bad practice) to to that (and often a mistake if not aware)...
additionally, it could cause strange effects like missing events in a parent widget.

I ran into the problem when having the following bad template (extremely simplified):

<div w-bind>
    <form w-bind w-onsubmit="handleSubmit">
        <div>
            <button>Submit</button>
        </div>
   </form>
</div>

Be aware of the 2 w-bind attributes!

further having (in the widget implementation code):

handleSubmit: function(event, el) {
    this.emit('submit', {});
    event.preventDefault();
}

PROBLEM: The "submit" event of the form emitted by this widget would never reach the parent widget.

@maberer
Copy link
Contributor Author

maberer commented Sep 22, 2015

People might use the following statement with multiple w-bind. This would (at least) not cause strange effects (since the two sections are mutual exclusive...) - but I think it is bad practice nevertheless...

<if test="isLink">
    <a w-bind> ... </a>
</if>
<else>
    <button w-bind> ... </button>
</else>

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

1 participant