Closed ryoppippi closed 1 month ago
I build with minify=false
option
Maybe: https://github.com/sveltejs/svelte/blob/14ecedf33b04d74396372e93ffb0458b36b57761/packages/svelte/src/internal/client/dom/elements/attributes.js#L88
import { q as queue_micro_task, h as hydrating, B as get_prototype_of, L as LOADING_ATTR_SYMBOL, C as get_descriptors } from "./runtime.B7Evkmdu.js";
import { d as is_capture_event, e as create_event, f as delegate, n as normalize_attribute, g as is_delegated } from "./disclose-version.hcw21kbQ.js";
function autofocus(dom, value) {
if (value) {
const body = document.body;
dom.autofocus = true;
queue_micro_task(() => {
if (document.activeElement === body) {
dom.focus();
}
});
}
}
function set_attribute(element, attribute, value, skip_warning) {
var attributes = element.__attributes ?? (element.__attributes = {});
if (hydrating) {
attributes[attribute] = element.getAttribute(attribute); //causes an error!!!!
if (attribute === "src" || attribute === "srcset" || attribute === "href" && element.nodeName === "LINK") {
return;
}
}
if (attributes[attribute] === (attributes[attribute] = value)) return;
if (attribute === "loading") {
element[LOADING_ATTR_SYMBOL] = value;
}
if (value == null) {
element.removeAttribute(attribute);
} else if (typeof value !== "string" && get_setters(element).includes(attribute)) {
element[attribute] = value;
} else {
element.setAttribute(attribute, value);
}
}
function set_attributes(element, prev, next, css_hash, preserve_attribute_case = false, skip_warning) {
var current = prev || {};
var is_option_element = element.tagName === "OPTION";
for (var key in prev) {
if (!(key in next)) {
next[key] = null;
}
}
if (css_hash !== void 0) {
next.class = next.class ? next.class + " " + css_hash : css_hash;
}
var setters = setters_cache.get(element.nodeName);
if (!setters) setters_cache.set(element.nodeName, setters = get_setters(element));
var attributes = (
/** @type {Record<string, unknown>} **/
element.__attributes ?? (element.__attributes = {})
);
var events = [];
for (const key2 in next) {
let value = next[key2];
if (is_option_element && key2 === "value" && value == null) {
element.value = element.__value = "";
current[key2] = value;
continue;
}
var prev_value = current[key2];
if (value === prev_value) continue;
current[key2] = value;
var prefix = key2[0] + key2[1];
if (prefix === "$$") continue;
if (prefix === "on") {
const opts = {};
const event_handle_key = "$$" + key2;
let event_name = key2.slice(2);
var delegated = is_delegated(event_name);
if (is_capture_event(event_name)) {
event_name = event_name.slice(0, -7);
opts.capture = true;
}
if (!delegated && prev_value) {
if (value != null) continue;
element.removeEventListener(event_name, current[event_handle_key], opts);
current[event_handle_key] = null;
}
if (value != null) {
if (!delegated) {
let handle = function(evt) {
current[key2].call(this, evt);
};
if (!prev) {
events.push([
key2,
value,
() => current[event_handle_key] = create_event(event_name, element, handle, opts)
]);
} else {
current[event_handle_key] = create_event(event_name, element, handle, opts);
}
} else {
element[`__${event_name}`] = value;
delegate([event_name]);
}
}
} else if (value == null) {
attributes[key2] = null;
element.removeAttribute(key2);
} else if (key2 === "style") {
element.style.cssText = value + "";
} else if (key2 === "autofocus") {
autofocus(
/** @type {HTMLElement} */
element,
Boolean(value)
);
} else if (key2 === "__value" || key2 === "value") {
element.value = element[key2] = element.__value = value;
} else {
var name = key2;
if (!preserve_attribute_case) {
name = normalize_attribute(name);
}
if (setters.includes(name) && typeof value !== "string") {
element[name] = value;
} else if (typeof value !== "function") {
if (hydrating && (name === "src" || name === "href" || name === "srcset")) ;
else {
set_attribute(element, name, value);
}
}
}
}
if (!prev) {
queue_micro_task(() => {
if (!element.isConnected) return;
for (const [key2, value, evt] of events) {
if (current[key2] === value) {
evt();
}
}
});
}
return current;
}
var setters_cache = /* @__PURE__ */ new Map();
function get_setters(element) {
var setters = [];
var descriptors;
var proto = get_prototype_of(element);
while (proto.constructor.name !== "Element") {
descriptors = get_descriptors(proto);
for (var key in descriptors) {
if (descriptors[key].set) {
setters.push(key);
}
}
proto = get_prototype_of(proto);
}
return setters;
}
function handle_lazy_img(element) {
if (!hydrating && element.loading === "lazy") {
var src = element.src;
element[LOADING_ATTR_SYMBOL] = null;
element.loading = "eager";
element.removeAttribute("src");
requestAnimationFrame(() => {
if (element[LOADING_ATTR_SYMBOL] !== "eager") {
element.loading = "lazy";
}
element.src = src;
});
}
}
export {
set_attributes as a,
handle_lazy_img as h,
set_attribute as s
};
Got this issue with https://github.com/ntsd/sveltekit-html-minifier So, I'll create an issue for that
That sounds like you're removing whitespace and/or comments via the minifier, which Svelte is sensitive to. Try turning those parts off.
@dummdidumm Thanks for the info. I'll try the options later. For now, I'll turn off the minifier
Describe the bug
On production build, I got the error like this
works with next.226, still has issue.
The wired thing is that
Reproduction
URL: bc5543ca.lp-d1f.pages.dev Repo: https://github.com/vim-jp-radio/
I'll create minimal reproduction later
I can get the file which causes the error:
attributes.B_d_bZ2m.js
Logs
No response
System Info