fix #4852, break some other stuff

pull/4863/head
Richard Harris 5 years ago
parent c60418555e
commit 215c5e62e1

@ -53,8 +53,8 @@ export default class RawMustacheTagWrapper extends Tag {
const update_anchor = in_head ? 'null' : needs_anchor ? html_anchor : this.next ? this.next.var : 'null';
block.chunks.hydrate.push(b`${html_tag} = new @HtmlTag(${init}, ${update_anchor});`);
block.chunks.mount.push(b`${html_tag}.m(${parent_node || '#target'}, ${parent_node ? null : '#anchor'});`);
block.chunks.hydrate.push(b`${html_tag} = new @HtmlTag(${update_anchor});`);
block.chunks.mount.push(b`${html_tag}.m(${init}, ${parent_node || '#target'}, ${parent_node ? null : '#anchor'});`);
if (needs_anchor) {
block.add_element(html_anchor, x`@empty()`, x`@empty()`, parent_node);

@ -294,7 +294,7 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) {
} else if (unsubscribe && iframe.contentWindow) {
unsubscribe();
}
detach(iframe);
};
}
@ -319,29 +319,31 @@ export class HtmlTag {
t: HTMLElement;
a: HTMLElement;
constructor(html: string, anchor: HTMLElement = null) {
this.e = element('div');
constructor(anchor: HTMLElement = null) {
this.a = anchor;
this.u(html);
}
m(target: HTMLElement, anchor: HTMLElement = null) {
for (let i = 0; i < this.n.length; i += 1) {
insert(target, this.n[i], anchor);
m(html: string, target: HTMLElement, anchor: HTMLElement = null) {
if (!this.e) {
this.e = element(target.nodeName as keyof HTMLElementTagNameMap);
this.t = target;
}
this.t = target;
this.u(html, anchor);
}
u(html: string) {
u(html: string, anchor) {
this.e.innerHTML = html;
this.n = Array.from(this.e.childNodes);
for (let i = 0; i < this.n.length; i += 1) {
insert(this.t, this.n[i], anchor);
}
}
p(html: string) {
this.d();
this.u(html);
this.m(this.t, this.a);
this.u(html, this.a);
}
d() {

Loading…
Cancel
Save