When using an expression in stache that is supposed to render the result of a top-level not() call as a true or false string, e.g.
a basic aria-hidden="{{ not( this.expanded ) }}" as part of a disclosure widget, then the not converter will always render an empty string as a result.
It uses looksLikeOptions and then falsely (!!) assumes whenever an options argument is present, that the not converter is being used as a {{#not}} sectioning helper. This leads to cases such as the above example to effectively be interpreted as:
aria-hidden="{{#not ( this.expanded ) }}{{/not}}"
- i.e. to be interpreted as never rendering any actual content, because the sectioning templates are empty.
Here's also a screenshot of the above problem in action, with the debugger halted on the problematic conditional branch:
What the converter should be doing is strengthening that check with an additional check of the options.isSection property.
E.g.
How often can you reproduce it?
Description:
When using an expression in stache that is supposed to render the result of a top-level
not()
call as atrue
orfalse
string, e.g. a basicaria-hidden="{{ not( this.expanded ) }}"
as part of a disclosure widget, then the not converter will always render an empty string as a result.The root cause is in broken logic in the
not
converter's getter: https://github.com/canjs/can-stache/blob/17b727a5423abdfefa054462c7289da32c64ca88/helpers/core.js#L496-L507It uses
looksLikeOptions
and then falsely (!!) assumes whenever anoptions
argument is present, that thenot
converter is being used as a{{#not}}
sectioning helper. This leads to cases such as the above example to effectively be interpreted as:- i.e. to be interpreted as never rendering any actual content, because the sectioning templates are empty.
Here's also a screenshot of the above problem in action, with the debugger halted on the problematic conditional branch:![image](https://user-images.githubusercontent.com/442808/183882591-b8cb3aa6-6fbc-4bd8-b774-590c2d535cb2.png)
What the converter should be doing is strengthening that check with an additional check of the
options.isSection
property. E.g.Steps to reproduce:
See the description.
Expected results: The
not
converter handles the described case correctly and does not hit the sectioning helper logic branch.Actual results: The
not
converter handles the described case incorrectly and hits the sectioning helper logic branch.Environment: