ajsfw
Version:
Ajs Framework
57 lines (56 loc) • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var Node_1 = require("./Node");
var TextNode_1 = require("./TextNode");
var CommentNode_1 = require("./CommentNode");
var HTMLElement_1 = require("./HTMLElement");
var Document = (function (_super) {
__extends(Document, _super);
function Document() {
var _this = _super.call(this, Node_1.default.DOCUMENT_NODE, "#document", null) || this;
_this.__documentElement = _this.createElement("html");
_this.__head = _this.createElement("head");
_this.__documentElement.appendChild(_this.__head);
_this.__body = _this.createElement("body");
_this.__documentElement.appendChild(_this.__body);
return _this;
}
Object.defineProperty(Document.prototype, "documentElement", {
get: function () { return this.__documentElement; },
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "head", {
get: function () { return this.__head; },
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "body", {
get: function () { return this.__body; },
enumerable: true,
configurable: true
});
Document.prototype.createElement = function (name) {
return new HTMLElement_1.default(name, this);
};
Document.prototype.createTextNode = function (text) {
return new TextNode_1.default(text, this);
};
Document.prototype.createComment = function (text) {
return new CommentNode_1.default(text, this);
};
Document.prototype.getElementById = function (id) {
return this.__documentElement.getElementById(id);
};
Document.prototype.getElementsByClassName = function (name) {
return this.__documentElement.getElementsByClassName(name);
};
Document.prototype.getElementsByName = function (name) {
return this.__documentElement.getElementsByName(name);
};
Document.prototype.getElementsByTagName = function (name) {
return this.__documentElement.getElementsByTagName(name);
};
return Document;
}(Node_1.default));
exports.default = Document;