lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Inconsistent attribute ordering between static/dynamic nodes

Open nolanlawson opened this issue 4 months ago • 1 comments

Description

Due to the static content optimization, the ordering of attributes in the DOM may be inconsistent.

This is only an issue if you are relying on the iteration order of elm.attributes, or the exact string output of elm.outerHTML, or something like that.

Our Jest serializer also pretty-prints HTML, so the difference is smoothed over in that case.

Related: #4124

Steps to Reproduce

Repro

Static output:

<div data-foo="foo" data-bar="bar" class="clazzy" style="color: blue">yolo</div>

Dynamic output:

<div class="clazzy" style="color: blue" data-foo="foo" data-bar="bar">yolo</div>

Expected Results

The attribute order should be identical.

Actual Results

The attribute order is different.

nolanlawson avatar Apr 25 '24 17:04 nolanlawson