Remove dependance on global window and document (#2897)
* Remove dependance on global window and document * Use any available document, prioritising parent.ownerDocument * Fix mockDom for DocumentFragment, revert to better ownerDocument implementation * Simplify activeElement usage
This commit is contained in:
parent
5488953436
commit
8e7ef427e0
2 changed files with 22 additions and 17 deletions
|
|
@ -307,6 +307,7 @@ module.exports = function(options) {
|
|||
parentNode: null,
|
||||
childNodes: [],
|
||||
attributes: {},
|
||||
ownerDocument: $window.document,
|
||||
contains: function(child) {
|
||||
while (child != null) {
|
||||
if (child === this) return true
|
||||
|
|
@ -717,6 +718,7 @@ module.exports = function(options) {
|
|||
},
|
||||
createDocumentFragment: function() {
|
||||
return {
|
||||
ownerDocument: $window.document,
|
||||
nodeType: 11,
|
||||
nodeName: "#document-fragment",
|
||||
appendChild: appendChild,
|
||||
|
|
@ -738,6 +740,7 @@ module.exports = function(options) {
|
|||
get activeElement() {return activeElement},
|
||||
},
|
||||
}
|
||||
$window.document.defaultView = $window
|
||||
$window.document.documentElement = $window.document.createElement("html")
|
||||
appendChild.call($window.document.documentElement, $window.document.createElement("head"))
|
||||
$window.document.body = $window.document.createElement("body")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue