adobe / htlengine

An HTL (Sightly) Interpreter/Compiler for Node.js
Apache License 2.0
47 stars 20 forks source link

Unable to set 'button' as `data-sly-element` #223

Closed panec closed 4 years ago

panec commented 4 years ago

When calling following code when the value of link is false

<button data-sly-element="${ link ? 'a' : 'button'}">test</button>

expected outcome is:

<button>test</button>

but now it is

<div>test</div>
tripodsan commented 4 years ago

I think change the element to button is not allowed per elementName context. see https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#121-display-context

@raducotescu is this correct?

raducotescu commented 4 years ago

Yes, there's a limited number of elements that can be used with data-sly-element.

panec commented 4 years ago

@tripodsan while I agree that according to the spec it is not valid it is used in the official Adobe Core Components examples: https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/wcm/components/button/v1/button/button.html so I assume that it works in AEM environment. I would like to be able to have a parity of code between AEM implementation and the Node version. @tripodsan @raducotescu what do you think about this inconsistency?

tripodsan commented 4 years ago

hmm..., I think the behaviour might be slightly different and is implement wrongly here: since the original element is already a <button/>, changing to element name to <a> is allowed, but not to <button/> :-) so instead of defaulting to <div/>, it should probably default to whatever was originally used.

adobe-bot commented 4 years ago

:tada: This issue has been resolved in version 5.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: