Open rdner opened 8 years ago
I believe this is the same concern as https://github.com/patrick-steele-idem/morphdom/issues/39
To pass browser validation (and our conversion to HTML using fragments), the morph needs to do something like this b/c the head
can't exist alone.
morphdom(
fromNode,
"<document><head></head></document>"
)
Although I'm not sure of an exact solution. Leaving open for now. 👍
Morphing
<head>
element should have a different algorithm because we have a set of immutable elements such as:<style>
,<script>
and<link rel="stylesheet">
. Changing these element's attributes or re-creating of these elements causes style flickering and script reloading which breaks any app.My proposal would be:
src
value for<script>
andhref
value for<link rel="stylesheet">
. We need this for handling attributes re-ordering and changing of those attributes which are irrelevant for script or style reloading.<script>
,<style>
and<link rel="stylesheet">
nodes inside<head>
element if morphing to a new state requires to remove them.For example,
We have a head element:
New state is:
After morphing we have:
As far as I use morphdom inside Catberry.js, I have to implement a separate algorithm for solving this problem, you can see it here. But I believe you would come up with a better solution using morphdom approach.