Fixed issue with binding when binding to a falsy object (also added types.isNullOrundefined function).

This commit is contained in:
Nedyalko Nikolov
2015-04-20 14:24:17 +03:00
parent 9550ebc144
commit 6bb533dc30
7 changed files with 25 additions and 10 deletions

View File

@@ -44,7 +44,7 @@ export class Bindable extends dependencyObservable.DependencyObservable implemen
if (!bindingSource) {
bindingSource = this.bindingContext;
}
if (bindingSource) {
if (!types.isNullOrUndefined(bindingSource)) {
binding.bind(bindingSource);
}
}
@@ -109,7 +109,7 @@ export class Bindable extends dependencyObservable.DependencyObservable implemen
" targetProperty: " + binding.options.targetProperty +
" to the changed context: " + newValue, trace.categories.Binding);
binding.unbind();
if (newValue) {
if (!types.isNullOrUndefined(newValue)) {
binding.bind(newValue);
}
}
@@ -134,7 +134,7 @@ export class Binding {
}
public bind(obj: Object) {
if (!obj) {
if (types.isNullOrUndefined(obj)) {
throw new Error("Expected valid object reference as a source in the Binding.bind method.");
}
@@ -344,7 +344,7 @@ export class Binding {
currentObject = currentObject[properties[i]];
}
if (currentObject !== undefined && currentObject !== null) {
if (!types.isNullOrUndefined(currentObject)) {
options = {
instance: new WeakRef(currentObject),
property: properties[properties.length - 1]

View File

@@ -4,6 +4,7 @@ import dependencyObservable = require("ui/core/dependency-observable");
import view = require("ui/core/view");
import trace = require("trace");
import imageSource = require("image-source");
import types = require("utils/types");
var VIEWS_STATES = "_viewStates";
@@ -436,7 +437,7 @@ export class TabView extends common.TabView {
}
private _setNativeSelectedIndex(index: number) {
if (index === undefined || index === null) {
if (types.isNullOrUndefined(index)) {
return;
}

View File

@@ -6,6 +6,7 @@ import trace = require("trace");
import utils = require("utils/utils");
import view = require("ui/core/view");
import imageSource = require("image-source");
import types = require("utils/types");
// merge the exports of the common file with the exports of this file
declare var exports;
@@ -206,7 +207,7 @@ export class TabView extends common.TabView {
var newIndex = data.newValue;
trace.write("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + newIndex + ")", trace.categories.Debug);
if (newIndex === undefined || newIndex === null) {
if (types.isNullOrUndefined(newIndex)) {
return;
}