Comparing version 5.1.6 to 5.1.7
@@ -13,4 +13,4 @@ var trailingNewlineRegex = /\n[\s]+$/ | ||
var CODE_TAGS = [ | ||
'code', 'pre' | ||
var VERBATIM_TAGS = [ | ||
'code', 'pre', 'textarea' | ||
] | ||
@@ -65,3 +65,3 @@ | ||
if (TEXT_TAGS.indexOf(nodeName) === -1 && | ||
CODE_TAGS.indexOf(nodeName) === -1) { | ||
VERBATIM_TAGS.indexOf(nodeName) === -1) { | ||
value = lastChild.nodeValue | ||
@@ -77,3 +77,3 @@ .replace(leadingNewlineRegex, '') | ||
} | ||
} else if (CODE_TAGS.indexOf(nodeName) === -1) { | ||
} else if (VERBATIM_TAGS.indexOf(nodeName) === -1) { | ||
// The very first node in the list should not have leading | ||
@@ -102,3 +102,3 @@ // whitespace. Sibling text nodes should have whitespace if there | ||
if (TEXT_TAGS.indexOf(nodeName) === -1 && | ||
CODE_TAGS.indexOf(nodeName) === -1) { | ||
VERBATIM_TAGS.indexOf(nodeName) === -1) { | ||
value = lastChild.nodeValue | ||
@@ -117,3 +117,3 @@ .replace(leadingNewlineRegex, '') | ||
// where all whitespace must be preserved | ||
} else if (CODE_TAGS.indexOf(nodeName) === -1) { | ||
} else if (VERBATIM_TAGS.indexOf(nodeName) === -1) { | ||
value = lastChild.nodeValue | ||
@@ -120,0 +120,0 @@ .replace(leadingSpaceRegex, ' ') |
{ | ||
"name": "bel", | ||
"version": "5.1.6", | ||
"version": "5.1.7", | ||
"description": "A simple extension to native elements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -154,2 +154,13 @@ var test = require('tape') | ||
test('space in <textarea>', function (t) { | ||
t.plan(1) | ||
var result = bel` | ||
<textarea> Whitespace at beginning | ||
middle | ||
and end </textarea> | ||
` | ||
t.equal(result.outerHTML, '<textarea> Whitespace at beginning \n middle\n and end </textarea>', 'should preserve space') | ||
t.end() | ||
}) | ||
test('for attribute is set correctly', function (t) { | ||
@@ -156,0 +167,0 @@ t.plan(1) |
37267
980