Remove html comments also.
This commit is contained in:
parent
9ca8459d19
commit
a3df7a5aad
2 changed files with 15 additions and 2 deletions
|
@ -114,6 +114,9 @@ class App.Utils
|
|||
# htmlOnlyWithRichtext = App.Utils.htmlRemoveRichtext( html )
|
||||
@htmlRemoveRichtext: (html) ->
|
||||
|
||||
# remove comments
|
||||
@_removeComments( html )
|
||||
|
||||
# remove style and class
|
||||
@_removeAttributes( html )
|
||||
|
||||
|
@ -130,6 +133,9 @@ class App.Utils
|
|||
# cleanHtmlWithRichText = App.Utils.htmlCleanup( html )
|
||||
@htmlCleanup: (html) ->
|
||||
|
||||
# remove comments
|
||||
@_removeComments( html )
|
||||
|
||||
# remove style and class
|
||||
@_removeAttributes( html )
|
||||
|
||||
|
@ -169,6 +175,13 @@ class App.Utils
|
|||
.removeAttr( 'title' )
|
||||
html
|
||||
|
||||
@_removeComments: (html) ->
|
||||
html.contents().each( ->
|
||||
if @nodeType == 8
|
||||
$(@).remove()
|
||||
)
|
||||
html
|
||||
|
||||
# signatureNeeded = App.Utils.signatureCheck( message, signature )
|
||||
@signatureCheck: (message, signature) ->
|
||||
messageText = $( '<div>' + message + '</div>' ).text().trim()
|
||||
|
|
|
@ -256,7 +256,7 @@ test( "htmlRemoveTags", function() {
|
|||
// htmlRemoveRichtext
|
||||
test( "htmlRemoveRichtext", function() {
|
||||
|
||||
var source = "<div><a href=\"test\">test</a></div>"
|
||||
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
|
||||
var should = "test"
|
||||
var result = App.Utils.htmlRemoveRichtext( $(source) )
|
||||
equal( result.html(), should, source )
|
||||
|
@ -330,7 +330,7 @@ test( "htmlRemoveRichtext", function() {
|
|||
// htmlCleanup
|
||||
test( "htmlCleanup", function() {
|
||||
|
||||
var source = "<div><a href=\"test\">test</a></div>"
|
||||
var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
|
||||
var should = "test"
|
||||
var result = App.Utils.htmlCleanup( $(source) )
|
||||
equal( result.html(), should, source )
|
||||
|
|
Loading…
Reference in a new issue