-
Notifications
You must be signed in to change notification settings - Fork 193
[PERF] Don't Attempt To Sanitize Unsanitizeable #429
base: master
Are you sure you want to change the base?
Conversation
such |
1e156d3
to
7e17f18
Compare
@@ -110,7 +110,7 @@ AttrMorph.prototype.setContent = function (value) { | |||
if (this.lastValue === value) { return; } | |||
this.lastValue = value; | |||
|
|||
if (this.escaped) { | |||
if (this.escaped && this.valueIdentity(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this just just mean all truthy things are left unescaped ?
On another unrelated note, the this.escaped
flag name sucks, we should have named it needsEscape
or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I don't understand what is going on here but if this.escape === true
, then the value we are trying to escape should be at least truthy. Currently we run the block with undefined
or strings. The sanitized value of undefined
will be undefined
, but clearly there is a micro-opt to be had here. I added the function instead of doing
if (this.escaped && value) {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, this aims to skips escaping if the value is falsy. As we believe no falsey values will need escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason for the method?
needs señor tests. |
This adds an identity check for falsy values before the value is sanitized. Currently we do work to sanitize things like `undefined`.
7e17f18
to
ad89efe
Compare
Not really sure how to test this as the sanitization function is local. Not sure how helpful the test is. |
@@ -17,6 +17,20 @@ test("can update a dom node", function(){ | |||
equal(element.getAttribute('id'), 'twang', 'id attribute is set'); | |||
}); | |||
|
|||
test("setting content to undefined calls _update with undefiend", function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "undefiend" should be "undefined"
This adds an identity check for falsy values before the value is
sanitized. Currently we do work to sanitize things like
undefined
.This is from a bench of a thousand
link-to
sBefore:
After: