Skip to content

Commit e3348f4

Browse files
committed
var names
1 parent 4515a6c commit e3348f4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

index.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -240,31 +240,32 @@ function hasAttrs (update) {
240240
function addAttrs (str, existing, update) {
241241
var attrs = []
242242

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])
246246

247247
var newAttrs = Object.assign({}, existing, update)
248248
var k = Object.keys(newAttrs)
249249
for (var i = 0; i < k.length; i++) {
250250
if (k[i][0] === '_') continue
251+
var attr = k[i]
251252

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] || '')
254255

255256
if (value == null) continue
256257

257-
attrs.push(' ' + k[i] + '="')
258+
attrs.push(' ' + attr + '="')
258259
if (typeof value === 'object' && !isStream(value)) {
259260
if (value.prepend) attrs.push(value.prepend)
260-
attrs.push(existing[k[i]])
261+
attrs.push(existing[attr])
261262
if (value.append) attrs.push(value.append)
262263
} else {
263264
attrs.push(value)
264265
}
265266
attrs.push('"')
266267
}
267-
attrs.push(x[2])
268+
attrs.push(tagParts[2])
268269
return attrs
269270
}
270271

0 commit comments

Comments
 (0)