zaro / node-htmlstrip-native

Nodejs module for stripping html tags
Other
21 stars 7 forks source link

Strange behaviour of `include_attributes` option, when set to `false` #14

Closed hooke closed 9 years ago

hooke commented 9 years ago

I've installed this module with version: "0.1.1" using npm.

include_attributes option behaves in some strange way:

if I use the following options:

var options = {
 include_script : false,
 include_style : false,
 compact_whitespace : true,
 include_attributes : {
   'alt': false
    }
  };

html text like

var html = '<style>b {color: red;}</style>' +
' Yey, <b> No more,&nbsp;tags&amp;</b>' +
    '<img source="1.png" alt="smiley">';

is stripped down to Yey, No more, tags& smiley - but I will get the same result if set 'alt' to true!

so, if I want to strip down alt attribute, I have to remove include_attributes option at all, or use like this: include_attributes : { }, so abovementioned html text is correctly stripped to Yey, No more, tags&

zaro commented 9 years ago

Yeah, the value was not used at all, the presense of the key was used as flag to include the tag. Fixed in 0.1.3