diff --git a/lib/static.js b/lib/static.js index bdd6f55057..679930be99 100644 --- a/lib/static.js +++ b/lib/static.js @@ -119,8 +119,8 @@ exports.text = function(elems) { for (var i = 0; i < len; i++) { elem = elems[i]; - if (elem.type === 'text' && elem.tagName != 'script' && elem.tagName != 'style') ret += elem.data; - else if (elem.children && elem.type !== 'comment' && elem.tagName != 'script' && elem.tagName != 'style') { + if (elem.type === 'text') ret += elem.data; + else if (elem.children && elem.type !== 'comment' && elem.tagName !== 'script' && elem.tagName !== 'style') { ret += exports.text(elem.children); } } diff --git a/test/api/utils.js b/test/api/utils.js index 55f9a4cbee..d6983c8a1c 100644 --- a/test/api/utils.js +++ b/test/api/utils.js @@ -66,6 +66,11 @@ describe('cheerio', function() { expect($.text()).to.equal(''); }); + it('(cheerio object) : should include text contents of children omiting style and script tags', function(){ + var $ = cheerio.load('
Welcome