Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

Commit 7e17f18

Browse files
committed
[PERF] Don't Attempt To Sanitive Unsanitizeable
This adds an identity check for falsy values before the value is sanitized. Currently we do work to sanitize things like `undefined`.
1 parent b0994e1 commit 7e17f18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/morph-attr/lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ AttrMorph.prototype.setContent = function (value) {
110110
if (this.lastValue === value) { return; }
111111
this.lastValue = value;
112112

113-
if (this.escaped) {
113+
if (this.escaped && this.valueIdentity(value)) {
114114
var sanitized = sanitizeAttributeValue(this.domHelper, this.element, this.attrName, value);
115115
this._update(sanitized, this.namespace);
116116
} else {
@@ -123,6 +123,11 @@ AttrMorph.prototype.getContent = function () {
123123
return value;
124124
};
125125

126+
// Used in conditional expression for truthiness
127+
AttrMorph.prototype.valueIdentity = function (value) {
128+
return value;
129+
};
130+
126131
// renderAndCleanup calls `clear` on all items in the morph map
127132
// just before calling `destroy` on the morph.
128133
//

0 commit comments

Comments
 (0)