Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/morph-attr/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ AttrMorph.prototype.setContent = function (value) {
if (this.lastValue === value) { return; }
this.lastValue = value;

if (this.escaped) {
if (this.escaped && value) {
var sanitized = sanitizeAttributeValue(this.domHelper, this.element, this.attrName, value);
this._update(sanitized, this.namespace);
} else {
Expand Down
14 changes: 14 additions & 0 deletions packages/morph-attr/tests/attr-morph-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){

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"

var element = domHelper.createElement('div');
var morph = domHelper.createAttrMorph(element, 'id');
var update = morph._setContent;
var calledWith;
morph.setContent(undefined);
morph._update = function(value) {
calledWith = value;
return update.apply(morph, arguments);
};
ok(calledWith === undefined);
equal(element.id, '');
});

test("can clear", function(){
expect(0);
var element = domHelper.createElement('div');
Expand Down