Skip to content

Commit

Permalink
Ensure that text/value bindings treat "null" and "undefined" gracious…
Browse files Browse the repository at this point in the history
…ly (display in UI as empty string)
  • Loading branch information
SteveSanderson committed Dec 19, 2010
1 parent 001ea5a commit 920c3f8
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 54 deletions.
7 changes: 6 additions & 1 deletion build/output/knockout-latest.debug.js
Expand Up @@ -830,8 +830,11 @@ ko.exportSymbol('ko.toJSON', ko.toJSON);(function () {
break;
}
}
} else
} else {
if ((value === null) || (value === undefined))
value = "";
element.value = value;
}
}
};
})();
Expand Down Expand Up @@ -1221,6 +1224,8 @@ ko.bindingHandlers['selectedOptions'] = {
ko.bindingHandlers['text'] = {
'update': function (element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
if ((value === null) || (value === undefined))
value = "";
typeof element.innerText == "string" ? element.innerText = value
: element.textContent = value;
}
Expand Down

0 comments on commit 920c3f8

Please sign in to comment.