Skip to content

Commit

Permalink
Add document.createComment Conflicts: index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes authored and lauriro committed Apr 1, 2014
1 parent ae209ff commit fa49b80
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[GitHub repo]: https://github.com/litejs/dom-lite


@version 0.0.2
@version 0.0.3
@date 2014-04-01
@stability 2 - Unstable

Expand Down
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ extend(Text, Node, {
nodeName: "#text"
})

function Comment(value) {
this.textContent = value
}

extend(Comment, Node, {
nodeType: 8,
nodeName: "#comment",
toString: function() {
return "<!--" + this.textContent + "-->"
}
})

function Document(){
this.body = this.createElement("body")
}
Expand All @@ -266,6 +278,9 @@ extend(Document, Node, {
createTextNode: function(value) {
return new Text(value)
},
createCommentNode: function(value) {
return new Comment(value)
},
createDocumentFragment: function() {
return new DocumentFragment()
},
Expand All @@ -289,4 +304,3 @@ module.exports = {
HTMLElement: HTMLElement
}


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dom-lite",
"version": "0.0.2",
"version": "0.0.3",
"stability": 2,
"license": "MIT",
"author": "Lauri Rooden <lauri@rooden.ee>",
Expand Down
6 changes: 6 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ test("can create nodes", function (assert) {
assert.equal(el.nodeName, "#text")
assert.equal(el.textContent, "hello")

el = document.createCommentNode("hello comment")
assert.equal(el.nodeType, 8)
assert.equal(el.nodeName, "#comment")
assert.equal(el.textContent, "hello comment")
assert.equal(el.outerHTML, "<!--hello comment-->")

assert.end()
})

Expand Down

0 comments on commit fa49b80

Please sign in to comment.