TeXZilla icon indicating copy to clipboard operation
TeXZilla copied to clipboard

switch observer model in custom element?

Open bkardell opened this issue 6 years ago • 0 comments

I was thinking the other day that the observer model is kind of flawed for custom elements because the lifecycle is so wonky... for example, currently

document.body.innerHTML = `<la-tex>f(x)=\\sum_{n=-\\infty}^\\infty c_n e^{2\\pi i(n/T) x} = \\sum_{n=-\\infty}^\\infty \\hat{f}(\\xi_n) e^{2\\pi i\\xi_n x}\\Delta\\xi</la-text>`

Will fail to fire (as would I if you included this at the end of your document, probably) as the nodes already exist - so they aren't being treated 'as parsed'. I think I added this this way and just never added the workarounds.... But.... I think the simplest one is to actually just not use a mutationobserver directly at all and make use of the slotchange event which seems to happen regardless, consistently... Maybe we should switch to use that? Something kinda like this https://glitch.com/edit/#!/mathml-examples?path=js/elements/la-tex.js:21:5 (though, obvs we'd rework a little to include attrs correctly too here?) The above snip will work if you try it in the console on https://mathml-examples.glitch.me/foundation-expansion.html

If we want I can work this up and send a pull...

bkardell avatar Oct 08 '19 22:10 bkardell