Skip to content

Commit

Permalink
Merge pull request #3579 from tcrowe/set-attribute-only-if-different
Browse files Browse the repository at this point in the history
Prevent image flicker and reloading by checking attribute before setting it
  • Loading branch information
Rich-Harris authored Oct 17, 2019
2 parents 6966c5b + 552f19b commit 99911c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function self(fn) {

export function attr(node: Element, attribute: string, value?: string) {
if (value == null) node.removeAttribute(attribute);
else node.setAttribute(attribute, value);
else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);
}

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

0 comments on commit 99911c3

Please sign in to comment.