Skip to content

Commit 99911c3

Browse files
authored
Merge pull request #3579 from tcrowe/set-attribute-only-if-different
Prevent image flicker and reloading by checking attribute before setting it
2 parents 6966c5b + 552f19b commit 99911c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/internal/dom.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function self(fn) {
8686

8787
export function attr(node: Element, attribute: string, value?: string) {
8888
if (value == null) node.removeAttribute(attribute);
89-
else node.setAttribute(attribute, value);
89+
else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);
9090
}
9191

9292
export function set_attributes(node: Element & ElementCSSInlineStyle, attributes: { [x: string]: string }) {

0 commit comments

Comments
 (0)