diff --git a/docs/src/demos/Experiments/Details/details-summary.ts b/docs/src/demos/Experiments/Details/details-summary.ts index 03feeb49..e796bfb7 100644 --- a/docs/src/demos/Experiments/Details/details-summary.ts +++ b/docs/src/demos/Experiments/Details/details-summary.ts @@ -11,7 +11,9 @@ export default Node.create({ content: 'inline*', - // group: 'block', + group: 'block', + + isolating: true, defaultOptions: { HTMLAttributes: {}, diff --git a/docs/src/demos/Experiments/Details/details.ts b/docs/src/demos/Experiments/Details/details.ts index a58dadf7..4dc8d02c 100644 --- a/docs/src/demos/Experiments/Details/details.ts +++ b/docs/src/demos/Experiments/Details/details.ts @@ -29,26 +29,8 @@ export default Node.create({ }, addNodeView() { - return ({ - HTMLAttributes, - }) => { + return ({ HTMLAttributes }) => { const item = document.createElement('details') - let open = false - - item.addEventListener('click', event => { - // @ts-ignore - const { localName } = event.target - - if (localName === 'summary') { - open = !open - - if (open) { - item.setAttribute('open', 'open') - } else { - item.removeAttribute('open') - } - } - }) Object.entries(HTMLAttributes).forEach(([key, value]) => { item.setAttribute(key, value) @@ -57,25 +39,9 @@ export default Node.create({ return { dom: item, contentDOM: item, - ignoreMutation: (updatedNode: MutationRecord) => { - // @ts-ignore - console.log({ updatedNode }, 'ignoreMutation', updatedNode.attributeName === 'open') - - return updatedNode.attributeName === 'open' + ignoreMutation: (mutation: MutationRecord) => { + return !item.contains(mutation.target) || item === mutation.target }, - // update: updatedNode => { - // if (updatedNode.type !== this.type) { - // return false - // } - - // if (updatedNode.attrs.open) { - // item.setAttribute('open', 'open') - // } else { - // item.removeAttribute('open') - // } - - // return true - // }, } } },