|
|
|
@ -64,6 +64,9 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
|
|
|
|
/** @type {boolean} */
|
|
|
|
/** @type {boolean} */
|
|
|
|
is_src;
|
|
|
|
is_src;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {boolean} */
|
|
|
|
|
|
|
|
is_srcset;
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {boolean} */
|
|
|
|
/** @type {boolean} */
|
|
|
|
is_select_value_attribute;
|
|
|
|
is_select_value_attribute;
|
|
|
|
|
|
|
|
|
|
|
|
@ -120,6 +123,9 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
|
|
|
|
this.is_src =
|
|
|
|
this.is_src =
|
|
|
|
this.name === 'src' &&
|
|
|
|
this.name === 'src' &&
|
|
|
|
(!this.parent.node.namespace || this.parent.node.namespace === namespaces.html);
|
|
|
|
(!this.parent.node.namespace || this.parent.node.namespace === namespaces.html);
|
|
|
|
|
|
|
|
this.is_srcset =
|
|
|
|
|
|
|
|
this.name === 'srcset' &&
|
|
|
|
|
|
|
|
(!this.parent.node.namespace || this.parent.node.namespace === namespaces.html);
|
|
|
|
this.should_cache = should_cache(this);
|
|
|
|
this.should_cache = should_cache(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -164,6 +170,11 @@ export default class AttributeWrapper extends BaseAttributeWrapper {
|
|
|
|
b`if (!@src_url_equal(${element.var}.src, ${init})) ${method}(${element.var}, "${name}", ${this.last});`
|
|
|
|
b`if (!@src_url_equal(${element.var}.src, ${init})) ${method}(${element.var}, "${name}", ${this.last});`
|
|
|
|
);
|
|
|
|
);
|
|
|
|
updater = b`${method}(${element.var}, "${name}", ${should_cache ? this.last : value});`;
|
|
|
|
updater = b`${method}(${element.var}, "${name}", ${should_cache ? this.last : value});`;
|
|
|
|
|
|
|
|
} else if (this.is_srcset) {
|
|
|
|
|
|
|
|
block.chunks.hydrate.push(
|
|
|
|
|
|
|
|
b`if (!@srcset_url_equal(${element.var}, ${init})) ${method}(${element.var}, "${name}", ${this.last});`
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
updater = b`${method}(${element.var}, "${name}", ${should_cache ? this.last : value});`;
|
|
|
|
} else if (property_name) {
|
|
|
|
} else if (property_name) {
|
|
|
|
block.chunks.hydrate.push(b`${element.var}.${property_name} = ${init};`);
|
|
|
|
block.chunks.hydrate.push(b`${element.var}.${property_name} = ${init};`);
|
|
|
|
updater = block.renderer.options.dev
|
|
|
|
updater = block.renderer.options.dev
|
|
|
|
@ -403,7 +414,7 @@ Object.keys(attribute_lookup).forEach((name) => {
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {AttributeWrapper} attribute */
|
|
|
|
/** @param {AttributeWrapper} attribute */
|
|
|
|
function should_cache(attribute) {
|
|
|
|
function should_cache(attribute) {
|
|
|
|
return attribute.is_src || attribute.node.should_cache();
|
|
|
|
return attribute.is_src || attribute.is_srcset || attribute.node.should_cache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const regex_contains_checked_or_group = /checked|group/;
|
|
|
|
const regex_contains_checked_or_group = /checked|group/;
|
|
|
|
|
|
|
|
|
|
|
|
|