10000 GitHub · Where software is built
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
webc:if="false" sticks when used in void elements #217
Open
@geofflambeth

Description

@geofflambeth

As best I can tell, using void elements with webc:if="false" (or in practice, with a variable or function that returns false) doesn't return anything with webc:else or webc:elseif until an end tag or a webc:if="true" comes along. I wasn't able to find this documented in the subtleties and limitations section of the webc docs or in the existing issues, I hope I haven't just missed it.

Trying to work around it for now. Would love if anyone had thoughts!

Example with no end tags

<meta webc:if="true" name="test1" content="this should be returned">
<meta webc:else name="test1" content="this should not be returned">
<!-- should return with test1 -->

<meta webc:if="false" name="test2" content="this should not be returned">
<meta webc:else name="test2" content="this should be returned">
<!-- if is false, should return else -->

<meta webc:if="false" name="test3" content="this should not be returned">
<meta webc:else name="test3" content="this should be returned">
<!-- if is false, should return else -->

<meta webc:if="false" name="test4" content="this not should be returned">
<meta webc:elseif="true" name="test4" content="this should be returned">
<meta webc:else name="test4" content="this should not be returned">
<!-- elseif is true, should return elseif -->

<meta webc:if="true" name="test5" content="this should be returned">
<meta webc:else name="test5" content="this should not be returned">
<!-- if is true, should return elseif -->

Instead of returning with 5 meta tags, each with a unique "name" attribute and with "this should be returned" in the content attribute, this returns only 2 meta tags:

<meta name="test1" content="this should be returned">

<!-- should return with test1 -->



<!-- if is false, should return else -->



<!-- if is false, should return else -->




<!-- elseif is true, should return elseif -->

<meta name="test5" content="this should be returned">

<!-- if is true, should return elseif -->

Example with end tags before each webc:if, closer to expected behavior

<meta webc:if="true" name="test1" content="this should be returned">
<meta webc:else name="test1" content="this should not be returned">
<!-- should return with test1 -->

<div webc:ignore></div>
<meta webc:if="false" name="test2" content="this should not be returned">
<meta webc:else name="test2" content="this should be returned">
<!-- if is false, should return else -->

<div webc:ignore></div>
<meta webc:if="false" name="test3" content="this should not be returned">
<meta webc:else name="test3" content="this should be returned">
<!-- if is false, should return else -->

<div webc:ignore></div>
<meta webc:if="false" name="test4" content="this not should be returned">
<meta webc:elseif="true" name="test4" content="this should be returned">
<meta webc:else name="test4" content="this should not be returned">
<!-- elseif is true, should return elseif -->

<div webc:ignore></div>
<meta webc:if="true" name="test5" content="this should be returned">
<meta webc:else name="test5" content="this should not be returned">
<!-- if is true, should return elseif -->

This returns what I expected to see originally, with all 4 meta tags in place.

<meta name="test1" content="this should be returned">

<!-- should return with test1 -->



<meta name="test2" content="this should be returned">
<!-- if is false, should return else -->



<meta name="test3" content="this should be returned">
<!-- if is false, should return else -->



<meta name="test4" content="this should be returned">

<!-- elseif is true, should return elseif -->


<meta name="test5" content="this should be returned">

<!-- if is true, should return elseif -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0