adobe / htl-spec

HTML Template Language Specification
Apache License 2.0
281 stars 145 forks source link

Multiple data-sly-attribute on one htl tag #92

Closed bartoszWesolowski closed 3 years ago

bartoszWesolowski commented 3 years ago

When multiple data-sly-attribute="${model.map}" are used on single HTL element only the last one is evaluated. Given that the model and model2 have a method map that return a String -> String map the following HTL code will not render attributes defined in model2.map

// model1.map -> {'a' : 'val a'}
// model2.map -> {'b': 'val b' }
  <div
      data-sly-use.model1="com.Model1"
      data-sly-use.model2="com.Model2"
      data-sly-attribute="${model1.map}"
      data-sly-attribute="${model2.map}">
  </div>

Expected Behaviour

Expected HTML output

  <div  a="val a" b="val b"></div>

Actual Behaviour

Actual HTL output

  <div b="val b"></div>

Platform and Version

AEM 6.5.6

raducotescu commented 3 years ago

@bartoszWesolowski, this looks like an implementation bug rather than a spec one. I opened https://issues.apache.org/jira/browse/SLING-10177 for it.

bartoszWesolowski commented 3 years ago

Cool, thanks @raducotescu

raducotescu commented 3 years ago

@bartoszWesolowski, after a second look at this I can actually confirm that what you're reporting is not a bug. In the HTML 5 specification, specifically in the HTML syntax chapter dedicated to attributes [0], there's this paragraph:

There must never be two or more attributes on the same start tag whose names are an ASCII case-insensitive match for each other.

In this case, you essentially have two data-sly-attribute attributes on the same start tag.

[0] - https://html.spec.whatwg.org/multipage/syntax.html#attributes-2