On cleanup remove also id and data- attributes.
This commit is contained in:
parent
5e7468e8a8
commit
bee011d030
3 changed files with 25 additions and 3 deletions
|
@ -205,13 +205,16 @@ class App.Utils
|
||||||
.removeAttr('title')
|
.removeAttr('title')
|
||||||
.removeAttr('lang')
|
.removeAttr('lang')
|
||||||
.removeAttr('type')
|
.removeAttr('type')
|
||||||
|
.removeAttr('id')
|
||||||
|
.removeAttrs(/data-/)
|
||||||
html
|
html
|
||||||
.removeAttr('style')
|
.removeAttr('style')
|
||||||
.removeAttr('class')
|
.removeAttr('class')
|
||||||
.removeAttr('title')
|
.removeAttr('title')
|
||||||
.removeAttr('lang')
|
.removeAttr('lang')
|
||||||
.removeAttr('type')
|
.removeAttr('type')
|
||||||
|
.removeAttr('id')
|
||||||
|
.removeAttrs(/data-/)
|
||||||
html
|
html
|
||||||
|
|
||||||
@_removeComments: (html) ->
|
@_removeComments: (html) ->
|
||||||
|
|
|
@ -174,13 +174,27 @@ jQuery.event.special.remove = {
|
||||||
// native checkbox focus behaviour is the following:
|
// native checkbox focus behaviour is the following:
|
||||||
// tab to checkbox: :focus state and focus outline
|
// tab to checkbox: :focus state and focus outline
|
||||||
// click on checkbox: :focus state but no focus outline
|
// click on checkbox: :focus state but no focus outline
|
||||||
$('body').on('click', '.checkbox-replacement, .radio-replacement', function(event){
|
$('body').on('click', '.checkbox-replacement, .radio-replacement', function(event){
|
||||||
$(event.currentTarget).find('input').addClass('is-active')
|
$(event.currentTarget).find('input').addClass('is-active')
|
||||||
});
|
});
|
||||||
$('body').on('blur', '.checkbox-replacement input, .radio-replacement input', function(){
|
$('body').on('blur', '.checkbox-replacement input, .radio-replacement input', function(){
|
||||||
$(this).removeClass('is-active')
|
$(this).removeClass('is-active')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// remove attributes by regex
|
||||||
|
// http://stackoverflow.com/questions/8968767/remove-multiple-html5-data-attributes-with-jquery
|
||||||
|
jQuery.fn.removeAttrs = function(regex) {
|
||||||
|
return this.each(function() {
|
||||||
|
var $this = $(this),
|
||||||
|
names = [];
|
||||||
|
$.each(this.attributes, function(i, attr) {
|
||||||
|
if (attr && attr.specified && regex.test(attr.name)) {
|
||||||
|
$this.removeAttr(attr.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// start application
|
// start application
|
||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
new App.Run();
|
new App.Run();
|
||||||
|
|
|
@ -432,6 +432,11 @@ test("htmlCleanup", function() {
|
||||||
result = App.Utils.htmlCleanup($(source))
|
result = App.Utils.htmlCleanup($(source))
|
||||||
equal(result.html(), should, source)
|
equal(result.html(), should, source)
|
||||||
|
|
||||||
|
source = "<div><p id=\"123\" data-id=\"abc\">some link to somewhere</p></div>"
|
||||||
|
should = "<p>some link to somewhere</p>"
|
||||||
|
result = App.Utils.htmlCleanup($(source))
|
||||||
|
equal(result.html(), should, source)
|
||||||
|
|
||||||
source = "<div><small>some link to somewhere</small></a>"
|
source = "<div><small>some link to somewhere</small></a>"
|
||||||
//should = "<div>some link to somewhere</div>"
|
//should = "<div>some link to somewhere</div>"
|
||||||
should = "some link to somewhere"
|
should = "some link to somewhere"
|
||||||
|
|
Loading…
Reference in a new issue