Closed brandonpayton closed 8 years ago
Thanks for reporting this issue !
render(parent)
should be render(container, parent)
. Would be great to be able to put this issue in evidence in a spec. Since you stumbled on this issue you probably know how we can reproduce it ?document.createDocumentFragment()
was more a hack since IE was slow as hell when trying to add nodes to the DOM directly one by one. created
should be a post creation hook and it's indeed an issue with fragments. And I've no idea how to solve that since a fragment can live in memory and it's not possible to catch when it'll be effectively added in the DOM.dom-layer
as a low level library. I'm personnaly using it in a higher abstraction so I don't need to take care about the low level API. I think it was the strategy which minimizes "ugly code" but I may be wrong.document.appendChild()
) should be a tag concern. Indeed tags should be responsible of rendering itself. This way you can create your own tags as well of even high level tags (like widget for example) and have them rendered correctly in the DOM. Imo the role of the tree is to simply call render()
methods, it's should need to know how each tag should be rendered.Sure I'm always open to new contributions when they make sense. I'll do my best to help if I can.
Cool. I think we are mostly on the same page.
I'll create a spec showing each issue along with separate GH issues and then a PR or two with fixes. I'll leave this issue open until then.
Hi @jails, after digging deeper, I began to think that I'd like to do things a bit differently than dom-layer
, so I've been playing around with creating an even simpler virtual DOM library using some of the same ideas. I planned to show you my thoughts at the very least, but due to a change in technical direction at work, I do not have much time to spend on either effort. However, I have repro steps for missing parent
that I'll file under a dedicated issue. I opened a dedicated issue about the created
hook as well.
Thank you for sharing your work, and I'll share mine if I get time to test and publish.
Hi @jails, thanks for your work on this library. The code is quite readable, and I'm enjoying working with it.
I'm creating this issue to discuss two issues because they both involve the same patching code, and it would be good to get your thoughts before splitting to a second issue.
Issues
parent
parent
.created
hook is called inconsistently relative to when its element is inserted in the DOM.Tag#render
, thecreated
hook is called after the node's element is inserted in the DOM, but whenTag#render
appends itself to a document fragment,created
is called before the node is added to the DOM document bytree/patch
.created
hooks may need to do things like take layout measurements which require being part of the document flow.Discussion
In case we both agree on the above, here are some thoughts and questions:
parent
, rendering, and insertion?parent
?parent
of itschildren
. Derived information such as an inheritednamespace
value could be determined onrender
if needed.parent
as a side-effect of the render operation.render
to take no arguments.tree
ornode
modules rather than spread across both.tree
modules<img>
which makes this thought sound less reasonable.append
and one forinsertBefore
.There may be more pros and cons, but that is what I'm able to think of at the moment.
What are you thoughts? I realize this is quite an opinionated brain dump.
Contributions
Are you up for taking contributions? If so, let me know what approach you'd like to take with these things (if any), and I am happy to do the work.
Thank you!