Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSanderson committed Mar 11, 2013
2 parents bf0c91e + 0192492 commit b97962d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion spec/bindingAttributeBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Binding attribute syntax', function() {
});

it('Should tolerate arbitrary literals as the values for a handler', function () {
testNode.innerHTML = "<div data-bind='stringLiteral: \"hello\", numberLiteral: 123, boolLiteral: true, objectLiteral: {}, functionLiteral: function() { }'></div>";
testNode.innerHTML = "<div data-bind='stringLiteral: \"hello\", numberLiteral: 123, boolLiteralTrue: true, boolLiteralFalse: false, objectLiteral: {}, functionLiteral: function() { }, nullLiteral: null, undefinedLiteral: undefined'></div>";
ko.applyBindings(null, testNode); // No exception means success
});

Expand Down
18 changes: 0 additions & 18 deletions spec/defaultBindings/checkedBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,6 @@ describe('Binding: Checked', function() {
expect(model.someProp).toEqual(true);
});

it('Should update observable properties on the underlying model when the checkbox is clicked', function () {
var myobservable = new ko.observable(false);
testNode.innerHTML = "<input type='checkbox' data-bind='checked:someProp' />";
ko.applyBindings({ someProp: myobservable }, testNode);

ko.utils.triggerEvent(testNode.childNodes[0], "click");
expect(myobservable()).toEqual(true);
});

it('Should update non-observable properties on the underlying model when the checkbox is clicked', function () {
var model = { someProp: false };
testNode.innerHTML = "<input type='checkbox' data-bind='checked:someProp' />";
ko.applyBindings(model, testNode);

ko.utils.triggerEvent(testNode.childNodes[0], "click");
expect(model.someProp).toEqual(true);
});

it('Should make a radio button checked if and only if its value matches the bound model property', function () {
var myobservable = new ko.observable("another value");
testNode.innerHTML = "<input type='radio' value='This Radio Button Value' data-bind='checked:someProp' />";
Expand Down
8 changes: 8 additions & 0 deletions spec/subscribableBehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ describe('Subscribable', function() {
expect(ko.isSubscribable(instance)).toEqual(true);
});

it('isSubscribable should return false for undefined', function () {
expect(ko.isSubscribable(undefined)).toEqual(false);
});

it('isSubscribable should return false for null', function () {
expect(ko.isSubscribable(null)).toEqual(false);
});

it('Should be able to notify subscribers', function () {
var instance = new ko.subscribable();
var notifiedValue;
Expand Down
2 changes: 1 addition & 1 deletion src/binding/expressionRewriting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ko.expressionRewriting = (function () {
var restoreCapturedTokensRegex = /\@ko_token_(\d+)\@/g;
var javaScriptReservedWords = ["true", "false"];
var javaScriptReservedWords = ["true", "false", "null", "undefined"];

// Matches something that can be assigned to--either an isolated identifier or something ending with a property accessor
// This is designed to be simple and avoid false negatives, but could produce false positives (e.g., a+b.c).
Expand Down
2 changes: 1 addition & 1 deletion src/subscribables/subscribable.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ko.subscribable['fn'] = {


ko.isSubscribable = function (instance) {
return typeof instance.subscribe == "function" && typeof instance["notifySubscribers"] == "function";
return instance != null && typeof instance.subscribe == "function" && typeof instance["notifySubscribers"] == "function";
};

ko.exportSymbol('subscribable', ko.subscribable);
Expand Down
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ko.utils = (function () {
},

addOrRemoveItem: function(array, value, included) {
var existingEntryIndex = array.indexOf ? array.indexOf(value) : utils.arrayIndexOf(array, value);
var existingEntryIndex = array.indexOf ? array.indexOf(value) : ko.utils.arrayIndexOf(array, value);
if (existingEntryIndex < 0) {
if (included)
array.push(value);
Expand Down Expand Up @@ -488,6 +488,8 @@ ko.exportSymbol('utils.range', ko.utils.range);
ko.exportSymbol('utils.toggleDomNodeCssClass', ko.utils.toggleDomNodeCssClass);
ko.exportSymbol('utils.triggerEvent', ko.utils.triggerEvent);
ko.exportSymbol('utils.unwrapObservable', ko.utils.unwrapObservable);
ko.exportSymbol('utils.objectForEach', ko.utils.objectForEach);
ko.exportSymbol('utils.addOrRemoveItem', ko.utils.addOrRemoveItem);

if (!Function.prototype['bind']) {
// Function.prototype.bind is a standard part of ECMAScript 5th Edition (December 2009, http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)
Expand Down

0 comments on commit b97962d

Please sign in to comment.