Summary
Img.JawsRender emits caller-supplied attributes before its canonical getter-derived src. HTML parsing keeps the first duplicate attribute, so a supported template.HTMLAttr parameter controls the initial image instead of the documented getter.
This silently violates the Img contract until a later JawsUpdate replaces the DOM attribute.
Public reproduction
err := rw.Img(
"getter.png",
template.HTMLAttr(`src="caller.png"`),
)
Current markup is equivalent to:
<img id="Jid.1" src="caller.png" src="getter.png">
The browser retains src="caller.png"; expected is getter.png.
This is supported API use: Img and NewImg document that src comes from the getter, while the ui parameter contract accepts raw template.HTMLAttr values and does not reserve src.
Root cause
lib/ui/img.go appends elem.ApplyParams(params) and getter attributes before appending the canonical srcAttr. Browsers retain the first duplicate attribute.
Proposed fix
Emit the canonical getter-derived src before caller and getter-provided attributes. This follows the canonical-attribute precedence already used for option values after #218.
Acceptance criteria
Summary
Img.JawsRenderemits caller-supplied attributes before its canonical getter-derivedsrc. HTML parsing keeps the first duplicate attribute, so a supportedtemplate.HTMLAttrparameter controls the initial image instead of the documented getter.This silently violates the
Imgcontract until a laterJawsUpdatereplaces the DOM attribute.Public reproduction
Current markup is equivalent to:
The browser retains
src="caller.png"; expected isgetter.png.This is supported API use:
ImgandNewImgdocument thatsrccomes from the getter, while theuiparameter contract accepts rawtemplate.HTMLAttrvalues and does not reservesrc.Root cause
lib/ui/img.goappendselem.ApplyParams(params)and getter attributes before appending the canonicalsrcAttr. Browsers retain the first duplicate attribute.Proposed fix
Emit the canonical getter-derived
srcbefore caller and getter-provided attributes. This follows the canonical-attribute precedence already used for option values after #218.Acceptance criteria
Imgwith a duplicate callersrcemits the getter value first.srcreturned through an initial-attribute hook also appears after the canonical getter value.srcparams and getter attributes remain present.srcescaping andJawsUpdatebehavior remain unchanged.