mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed issue with binding when binding to a falsy object (also added types.isNullOrundefined function).
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user