@@ -301,21 +301,22 @@ Syntax.Match.defaultReduceCallback = function (node, container) {
301
301
// Using jQuery jQuery.fn.append() can reduce performance by as much as 1/3rd.
302
302
if ( typeof ( node ) === 'string' ) {
303
303
node = document . createTextNode ( node ) ;
304
- } else {
305
- node = node [ 0 ] ;
306
304
}
307
305
308
- container [ 0 ] . appendChild ( node ) ;
306
+ container . appendChild ( node ) ;
309
307
} ;
310
308
311
309
Syntax . Match . prototype . reduce = function ( append , process ) {
312
310
var start = this . offset ;
313
- var container = jQuery ( '< span></span> ') ;
311
+ var container = document . createElement ( ' span') ;
314
312
315
313
append = append || Syntax . Match . defaultReduceCallback ;
316
314
317
315
if ( this . expression && this . expression . klass ) {
318
- container . addClass ( this . expression . klass ) ;
316
+ if ( container . className . length > 0 )
317
+ container . className += ' ' ;
318
+
319
+ container . className += this . expression . klass ;
319
320
}
320
321
321
322
for ( var i = 0 ; i < this . children . length ; i += 1 ) {
@@ -968,7 +969,8 @@ Syntax.Brush.prototype.process = function(text, matches) {
968
969
969
970
var lines = top . split ( / \n / g) ;
970
971
971
- var html = jQuery ( '<pre class="syntax"></pre>' ) ;
972
+ var html = document . createElement ( 'pre' ) ;
973
+ html . className = 'syntax' ;
972
974
973
975
for ( var i = 0 ; i < lines . length ; i += 1 ) {
974
976
var line = lines [ i ] . reduce ( null , function ( container , match ) {
@@ -987,7 +989,7 @@ Syntax.Brush.prototype.process = function(text, matches) {
987
989
return container ;
988
990
} ) ;
989
991
990
- html . append ( line ) ;
992
+ html . appendChild ( line ) ;
991
993
}
992
994
993
995
return html ;
@@ -1065,7 +1067,7 @@ Syntax.highlight = function (elements, options, callback) {
1065
1067
1066
1068
Syntax . highlightText ( text , options , function ( html , brush /*, text, options*/ ) {
1067
1069
Syntax . layouts . get ( options . layout , function ( layout ) {
1068
- html = layout ( options , html , container ) ;
1070
+ html = layout ( options , $ ( html ) , $ ( container ) ) ;
1069
1071
1070
1072
// If there is a theme specified, ensure it is added to the top level class.
1071
1073
if ( options . theme ) {
0 commit comments