nanomorph icon indicating copy to clipboard operation
nanomorph copied to clipboard

SVG use does not repaint in firefox upon second update

Open AndyOGo opened this issue 7 years ago • 3 comments

I just started using nanomorph and I have a simple test by changing the icon of an SVG icon sprite every second. Works perfectly in latest chrome but not in Firefox - see screencasts below:

[Edit]: I just realised that the xlink:href attribute isn't updated.

I use it to build Custom-elements with incremental rendering: https://github.com/axa-ch/patterns-library/pull/411

Latest Chrome: incremental-icon-chrome

Latest Firefox: incremental-icon-firefox-stops

AndyOGo avatar Apr 18 '18 14:04 AndyOGo

I opened my debugger and tracked it down, it seems to be caused by setting namespaced attributes without it's namespace, but rather by it's local name (it works in chrome because SVG's recent version of <use> tag dropped the xlink:href in favor of href)

https://github.com/choojs/nanomorph/blob/master/lib/morph.js#L50-L51

firefox-ns-attributes-updates

AndyOGo avatar Apr 18 '18 14:04 AndyOGo

Very interesting the DOM spec of getAttributeNS and setAttributeNS seems to be irritating. https://dom.spec.whatwg.org/#dom-element-getattributens

getAttributeNS(namespace, localName) https://www.w3.org/TR/DOM-Level-2-Core/glossary.html#dt-localname A local name is the local part of a qualified name. This is called the local part in Namespaces in XML [Namespaces].

setAttributeNS(namespace, qualifiedName, value) https://www.w3.org/TR/DOM-Level-2-Core/glossary.html#dt-qualifiedname A qualified name is the name of an element or attribute defined as the concatenation of a local name (as defined in this specification), optionally preceded by a namespace prefix and colon character. See Qualified Names in Namespaces in XML [Namespaces].

AndyOGo avatar Apr 18 '18 14:04 AndyOGo

I have just raised the same issue for morphdom https://github.com/patrick-steele-idem/morphdom/issues/124

AndyOGo avatar Apr 18 '18 18:04 AndyOGo