File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ var _ = require ( 'lodash' ) ;
2+
13/**
24 * Serializes HTML elements back to raw HTML
35 */
4-
56module . exports = {
67 /**
78 * @param {String } name
@@ -37,7 +38,7 @@ module.exports = {
3738 var res = '<' + tagName ;
3839
3940 attrs . forEach ( function ( attr ) {
40- res += ' ' + attr . name + '="' + escape ( attr . value ) + '"' ;
41+ res += ' ' + attr . name + '="' + _ . escape ( attr . value ) + '"' ;
4142 } ) ;
4243
4344 selfClosing && ( res += '/' ) ;
@@ -56,7 +57,7 @@ module.exports = {
5657 * @returns {String }
5758 */
5859 text : function ( text ) {
59- return text ;
60+ return _ . escape ( text ) ;
6061 } ,
6162 /**
6263 * @param {String } text
@@ -66,15 +67,3 @@ module.exports = {
6667 return '<!--' + text + '-->' ;
6768 }
6869} ;
69-
70- /**
71- * @param {String } str
72- * @returns {String }
73- */
74- function escape ( str ) {
75- return String ( str )
76- . replace ( / & / g, '&' )
77- . replace ( / " / g, '"' )
78- . replace ( / < / g, '<' )
79- . replace ( / > / g, '>' ) ;
80- }
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ describe('\'serialize\'', function () {
6363 it ( 'must serialize text' , function ( ) {
6464 var output = '\nblah\t"' ;
6565
66- serialize . text ( '\nblah\t" ' ) . must . be . equal ( output ) ;
66+ serialize . text ( '\nblah\t" ' ) . must . be . equal ( output ) ;
6767 } ) ;
6868
6969 it ( 'must serialize comments' , function ( ) {
You can’t perform that action at this time.
0 commit comments