diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index aa8847abc..cbd435b54 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -205,13 +205,16 @@ class App.Utils .removeAttr('title') .removeAttr('lang') .removeAttr('type') + .removeAttr('id') + .removeAttrs(/data-/) html .removeAttr('style') .removeAttr('class') .removeAttr('title') .removeAttr('lang') .removeAttr('type') - + .removeAttr('id') + .removeAttrs(/data-/) html @_removeComments: (html) -> diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index a9ca244c1..49e5c8bb3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -174,13 +174,27 @@ jQuery.event.special.remove = { // native checkbox focus behaviour is the following: // tab to checkbox: :focus state and 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') }); -$('body').on('blur', '.checkbox-replacement input, .radio-replacement input', function(){ +$('body').on('blur', '.checkbox-replacement input, .radio-replacement input', function(){ $(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 jQuery(function(){ new App.Run(); diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index 5424d7666..16473cd89 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -432,6 +432,11 @@ test("htmlCleanup", function() { result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) + source = "
some link to somewhere
some link to somewhere
" + result = App.Utils.htmlCleanup($(source)) + equal(result.html(), should, source) + source = "