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

Correct wording of warning message #743

Merged
merged 1 commit into from
Sep 5, 2020
Merged

Conversation

cie
Copy link
Contributor

@cie cie commented Sep 2, 2020

This warning message is a bit misleading, the template[x-if] tag requires a single child element, not a single child node (because text nodes are also nodes)

  • It can have some empty text nodes around the single child element
  • It's not good if it has a single text node as a child.

@HugoDF
Copy link
Contributor

HugoDF commented Sep 2, 2020

Do you have code samples of where the message would have been inaccurate?

@HugoDF
Copy link
Contributor

HugoDF commented Sep 2, 2020

Found one on Discord

<div x-data="{texts: ['hi', 'bye', 'sup']}">
    <template x-for="text in texts">
        Hola
        <div x-text="text"></div>
    </template>
</div>

Guess this PR makes sense

@cie
Copy link
Contributor Author

cie commented Sep 3, 2020

@HugoDF I thought about this case:

<div x-data="{greet: true}">
    <template x-if="greet">
        Hola
    </template>
</div>

@HugoDF
Copy link
Contributor

HugoDF commented Sep 3, 2020

Yep thanks @cie

This change makes sense, I think @calebporzio will merge it when he gets a chance

@calebporzio
Copy link
Collaborator

Thanks @cie!

@calebporzio calebporzio merged commit 999356a into alpinejs:master Sep 5, 2020
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.

4 participants