@@ -240,31 +240,32 @@ function hasAttrs (update) {
240
240
function addAttrs ( str , existing , update ) {
241
241
var attrs = [ ]
242
242
243
- // split the tag into two parts: `<tagname attrs ` and `>` (or `/>` for self closing)
244
- var x = str . match ( / ^ ( < \S + ) (?: .* ?) ( \/ ? > ) $ / )
245
- attrs . push ( x [ 1 ] )
243
+ // split the tag into two parts: `<tagname` and `>` (or `/>` for self closing)
244
+ var tagParts = str . match ( / ^ ( < \S + ) (?: .* ?) ( \/ ? > ) $ / )
245
+ attrs . push ( tagParts [ 1 ] )
246
246
247
247
var newAttrs = Object . assign ( { } , existing , update )
248
248
var k = Object . keys ( newAttrs )
249
249
for ( var i = 0 ; i < k . length ; i ++ ) {
250
250
if ( k [ i ] [ 0 ] === '_' ) continue
251
+ var attr = k [ i ]
251
252
252
- var value = newAttrs [ k [ i ] ]
253
- if ( typeof value === 'function' ) value = value ( existing [ k [ i ] ] || '' )
253
+ var value = newAttrs [ attr ]
254
+ if ( typeof value === 'function' ) value = value ( existing [ attr ] || '' )
254
255
255
256
if ( value == null ) continue
256
257
257
- attrs . push ( ' ' + k [ i ] + '="' )
258
+ attrs . push ( ' ' + attr + '="' )
258
259
if ( typeof value === 'object' && ! isStream ( value ) ) {
259
260
if ( value . prepend ) attrs . push ( value . prepend )
260
- attrs . push ( existing [ k [ i ] ] )
261
+ attrs . push ( existing [ attr ] )
261
262
if ( value . append ) attrs . push ( value . append )
262
263
} else {
263
264
attrs . push ( value )
264
265
}
265
266
attrs . push ( '"' )
266
267
}
267
- attrs . push ( x [ 2 ] )
268
+ attrs . push ( tagParts [ 2 ] )
268
269
return attrs
269
270
}
270
271
0 commit comments