Any time you call document.createElement (or its cousins, e.g. createDocumentFragment), the new node belongs to that document. It's my understanding that if you add that new node to a different document, then it will be updated to belong to that other document, and everything will work fine.
I'm writing a factory function that creates elements given tag type, attributes, and children. I would rather not have to pass the document in as a parameter.
In a situation where there are multiple documents pertaining to an application (e.g. an iframe, or a child window), if all you're doing is creating new nodes and adding them to some document, is there any disadvantage to creating all of those nodes on the topmost document? E.g. are there any semantic differences, or performance costs?