Merge pull request #3723 from sveltejs/always-set-attribute

don't cache attribute values
pull/3727/head
Rich Harris 5 years ago committed by GitHub
commit ba72fd2289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -95,7 +95,7 @@ export default class AttributeWrapper {
const is_select_value_attribute = const is_select_value_attribute =
name === 'value' && element.node.name === 'select'; name === 'value' && element.node.name === 'select';
const should_cache = (this.node.should_cache() || is_select_value_attribute); const should_cache = is_select_value_attribute; // TODO is this necessary?
const last = should_cache && block.get_unique_name( const last = should_cache && block.get_unique_name(
`${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value` `${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value`

@ -14,7 +14,6 @@ function create_fragment(ctx) {
let div0; let div0;
let t; let t;
let div1; let div1;
let div1_style_value;
return { return {
c() { c() {
@ -22,7 +21,7 @@ function create_fragment(ctx) {
t = space(); t = space();
div1 = element("div"); div1 = element("div");
attr(div0, "style", ctx.style); attr(div0, "style", ctx.style);
attr(div1, "style", div1_style_value = "" + (ctx.key + ": " + ctx.value)); attr(div1, "style", "" + (ctx.key + ": " + ctx.value));
}, },
m(target, anchor) { m(target, anchor) {
insert(target, div0, anchor); insert(target, div0, anchor);
@ -34,8 +33,8 @@ function create_fragment(ctx) {
attr(div0, "style", ctx.style); attr(div0, "style", ctx.style);
} }
if ((changed.key || changed.value) && div1_style_value !== (div1_style_value = "" + (ctx.key + ": " + ctx.value))) { if (changed.key || changed.value) {
attr(div1, "style", div1_style_value); attr(div1, "style", "" + (ctx.key + ": " + ctx.value));
} }
}, },
i: noop, i: noop,

Loading…
Cancel
Save