p4ulypops / jquery-clean

Automatically exported from code.google.com/p/jquery-clean
0 stars 0 forks source link

Removes attributes whose names contain a hyphen, e.g. html5 'data-' attributes. #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version 1.3.0

Attributes whose name contains a hyphen get removed, even if they are specified 
in the 'allowedAttributes' options.

This causes html5 data attributes (e.g. data-name="John") to be removed.

The cause of this is the 'attrsRE' regular expression in the code:
var attrsRE = /(\w+)=(".*?"|'.*?'|[^\s>]*)/gi;

This permits only word characters in the attribute name, (normally 
[A-Za-z0-9_]).

A fix is to replace it with:
var attrsRE = /([A-Za-z0-9_-]+)=(".*?"|'.*?'|[^\s>]*)/gi;

Original issue reported on code.google.com by paul.at....@gmail.com on 16 Jul 2012 at 10:11

GoogleCodeExporter commented 9 years ago
This is a duplicate of Issue 15, which has been fixed but is not currently 
included in a release.

Original comment by paul.at....@gmail.com on 18 Jul 2012 at 11:17

GoogleCodeExporter commented 9 years ago

Original comment by antixsof...@gmail.com on 25 Feb 2013 at 2:34