-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple elements in root with Fragments (#118)
* Use hyperx with createFragment support * Add tests for multiple elements * Add fragments to lib/browser * Add fragments to lib/browserify-transform * Add fragments to lib/babel * Messed up during rebase * Add docs for DocumentFragments
- Loading branch information
1 parent
fd4aa0d
commit 39831aa
Showing
8 changed files
with
137 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ require('./api.js') | |
require('./elements.js') | ||
require('./raw.js') | ||
require('./events.js') | ||
require('./multiple.js') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var test = require('tape') | ||
var html = require('../../') | ||
|
||
test('multiple elements', function (t) { | ||
var multiple = html`<li>Hamburg</li><li>Helsinki</li>haha<li>Berlin<div>test</div></li>` | ||
|
||
var list = document.createElement('ul') | ||
list.appendChild(multiple) | ||
t.equal(list.children.length, 3, '3 children') | ||
t.equal(list.childNodes.length, 4, '4 childNodes') | ||
t.equal(list.children[0].tagName, 'LI', 'list tag name') | ||
t.equal(list.children[0].textContent, 'Hamburg') | ||
t.equal(list.children[1].textContent, 'Helsinki') | ||
t.equal(list.children[2].textContent, 'Berlintest') | ||
t.equal(list.querySelector('div').textContent, 'test', 'created sub-element') | ||
t.equal(list.childNodes[2].nodeValue, 'haha') | ||
t.end() | ||
}) | ||
|
||
test('nested fragments', function (t) { | ||
var fragments = html`<div>1</div>ab${html`cd<div>2</div>between<div>3</div>`}<div>4</div>` | ||
t.equals(fragments.textContent, '1abcd2between34') | ||
t.equals(fragments.children.length, 4) | ||
t.equals(fragments.childNodes[4].textContent, 'between') | ||
t.equals(fragments.childNodes.length, 7) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters