FIX: don't reset open state on details tag when morphing (#702)
This commit is contained in:
parent
442681a3d3
commit
d555f18c6f
|
@ -67,6 +67,12 @@ class StreamUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostUpdater extends StreamUpdater {
|
class PostUpdater extends StreamUpdater {
|
||||||
|
morphingOptions = {
|
||||||
|
beforeAttributeUpdated: (element, attributeName) => {
|
||||||
|
return !(element.tagName === "DETAILS" && attributeName === "open");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
constructor(postStream, postId) {
|
constructor(postStream, postId) {
|
||||||
super();
|
super();
|
||||||
this.postStream = postStream;
|
this.postStream = postStream;
|
||||||
|
@ -116,13 +122,11 @@ class PostUpdater extends StreamUpdater {
|
||||||
async setCooked(value) {
|
async setCooked(value) {
|
||||||
this.post.set("cooked", value);
|
this.post.set("cooked", value);
|
||||||
|
|
||||||
const oldElement = this.postElement.querySelector(".cooked");
|
(await loadMorphlex()).morphInner(
|
||||||
|
this.postElement.querySelector(".cooked"),
|
||||||
// TODO: use `morphInner` once version morphlex 0.0.16 is out
|
`<div>${value}</div>`,
|
||||||
const newElement = oldElement.cloneNode(false);
|
this.morphingOptions
|
||||||
newElement.innerHTML = value;
|
);
|
||||||
|
|
||||||
(await loadMorphlex()).morph(oldElement, newElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get raw() {
|
get raw() {
|
||||||
|
|
Loading…
Reference in New Issue