Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate text node if not given an html tag. #9

Merged
merged 2 commits into from Nov 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion build/build.js
Expand Up @@ -5960,7 +5960,11 @@ function parse(html) {\n\
\n\
// tag name\n\
var m = /<([\\w:]+)/.exec(html);\n\
if (!m) throw new Error('No elements were generated.');\n\
if (!m) {\n\
var el = document.createElement('div');\n\
el.innerHTML = html;\n\
return el.lastChild\n\
}\n\
var tag = m[1];\n\
\n\
// body support\n\
Expand Down
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -40,7 +40,11 @@ function parse(html) {

// tag name
var m = /<([\w:]+)/.exec(html);
if (!m) throw new Error('No elements were generated.');
if (!m) {
var el = document.createElement('div');
el.innerHTML = html;
return el.lastChild
}
var tag = m[1];

// body support
Expand Down
6 changes: 6 additions & 0 deletions test/domify.js
Expand Up @@ -94,4 +94,10 @@ describe('domify(html)', function(){
assert(!el.parentElement);
assert(!el.parentNode);
})

it('should support text', function(){
var el = domify('text goes here');
assert('#text' == el.nodeName);
})
})