|
"use strict";
|
|
module.exports = DocumentFragment;
|
|
|
|
var Node = require('./Node');
|
|
var NodeList = require('./NodeList');
|
|
var ContainerNode = require('./ContainerNode');
|
|
var Element = require('./Element');
|
|
var select = require('./select');
|
|
var utils = require('./utils');
|
|
|
|
function DocumentFragment(doc) {
|
|
ContainerNode.call(this);
|
|
this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
|
|
this.ownerDocument = doc;
|
|
}
|
|
|
|
DocumentFragment.prototype = Object.create(ContainerNode.prototype, {
|
|
nodeName: { value: '#document-fragment' },
|
|
nodeValue: {
|
|
get: function() {
|
|
return null;
|
|
},
|
|
set: function() {}
|
|
},
|
|
|
|
textContent: Object.getOwnPropertyDescriptor(Element.prototype, 'textContent'),
|
|
|
|
|
|
innerText: Object.getOwnPropertyDescriptor(Element.prototype, 'innerText'),
|
|
|
|
querySelector: { value: function(selector) {
|
|
|
|
var nodes = this.querySelectorAll(selector);
|
|
return nodes.length ? nodes[0] : null;
|
|
}},
|
|
querySelectorAll: { value: function(selector) {
|
|
|
|
var context = Object.create(this);
|
|
|
|
|
|
context.isHTML = true;
|
|
context.getElementsByTagName = Element.prototype.getElementsByTagName;
|
|
context.nextElement =
|
|
Object.getOwnPropertyDescriptor(Element.prototype, 'firstElementChild').
|
|
get;
|
|
|
|
var nodes = select(selector, context);
|
|
return nodes.item ? nodes : new NodeList(nodes);
|
|
}},
|
|
|
|
|
|
clone: { value: function clone() {
|
|
return new DocumentFragment(this.ownerDocument);
|
|
}},
|
|
isEqual: { value: function isEqual(n) {
|
|
|
|
|
|
return true;
|
|
}},
|
|
|
|
|
|
innerHTML: {
|
|
get: function() { return this.serialize(); },
|
|
set: utils.nyi
|
|
},
|
|
outerHTML: {
|
|
get: function() { return this.serialize(); },
|
|
set: utils.nyi
|
|
},
|
|
|
|
});
|
|
|