From 7684eaa8965f6ede3fd6af579e2915224c8bdb3e Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 20 Jul 2022 20:58:43 +0800 Subject: [PATCH] jsx: viewFragment support null or undefined --- doric-js/bundle/doric-lib.es5.js | 2 +- doric-js/bundle/doric-lib.js | 2 +- doric-js/bundle/doric-vm.js | 2 +- doric-js/index.d.ts | 2 +- doric-js/lib/src/ui/view.d.ts | 2 +- doric-js/lib/src/ui/view.js | 2 +- doric-js/src/ui/view.es5.ts | 4 ++-- doric-js/src/ui/view.ts | 4 ++-- doric-web/dist/index.js | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doric-js/bundle/doric-lib.es5.js b/doric-js/bundle/doric-lib.es5.js index 3c845274..8a518539 100644 --- a/doric-js/bundle/doric-lib.es5.js +++ b/doric-js/bundle/doric-lib.es5.js @@ -716,7 +716,7 @@ var Group = /** @class */ (function (_super) { else if (e instanceof View) { this.addChild(e); } - else { + else if (!!e) { loge("Not allowed to add " + typeof e); } }; diff --git a/doric-js/bundle/doric-lib.js b/doric-js/bundle/doric-lib.js index 05361f9c..1dd23bfc 100644 --- a/doric-js/bundle/doric-lib.js +++ b/doric-js/bundle/doric-lib.js @@ -576,7 +576,7 @@ class Group extends Superview { else if (e instanceof View) { this.addChild(e); } - else { + else if (!!e) { loge(`Not allowed to add ${typeof e}`); } } diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index 8763219a..f04dbc60 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -2106,7 +2106,7 @@ class Group extends Superview { else if (e instanceof View) { this.addChild(e); } - else { + else if (!!e) { loge(`Not allowed to add ${typeof e}`); } } diff --git a/doric-js/index.d.ts b/doric-js/index.d.ts index 6a01c882..09d0846a 100644 --- a/doric-js/index.d.ts +++ b/doric-js/index.d.ts @@ -338,7 +338,7 @@ declare module 'doric/lib/src/ui/view' { toModel(): NativeViewModel; } export type ViewArray = View[]; - export type ViewFragment = View | ViewArray; + export type ViewFragment = View | ViewArray | undefined | null; export abstract class Group extends Superview implements JSX.ElementChildrenAttribute { readonly children: View[]; allSubviews(): View[]; diff --git a/doric-js/lib/src/ui/view.d.ts b/doric-js/lib/src/ui/view.d.ts index 835ee821..d82eda9f 100644 --- a/doric-js/lib/src/ui/view.d.ts +++ b/doric-js/lib/src/ui/view.d.ts @@ -157,7 +157,7 @@ export declare abstract class Superview extends View { toModel(): NativeViewModel; } export declare type ViewArray = View[]; -export declare type ViewFragment = View | ViewArray; +export declare type ViewFragment = View | ViewArray | undefined | null; export declare abstract class Group extends Superview implements JSX.ElementChildrenAttribute { readonly children: View[]; allSubviews(): View[]; diff --git a/doric-js/lib/src/ui/view.js b/doric-js/lib/src/ui/view.js index a4a63f31..0c3ac32a 100644 --- a/doric-js/lib/src/ui/view.js +++ b/doric-js/lib/src/ui/view.js @@ -458,7 +458,7 @@ export class Group extends Superview { else if (e instanceof View) { this.addChild(e); } - else { + else if (!!e) { loge(`Not allowed to add ${typeof e}`); } } diff --git a/doric-js/src/ui/view.es5.ts b/doric-js/src/ui/view.es5.ts index 59aadf92..d81c7c96 100644 --- a/doric-js/src/ui/view.es5.ts +++ b/doric-js/src/ui/view.es5.ts @@ -479,7 +479,7 @@ export abstract class Superview extends View { } export type ViewArray = View[] -export type ViewFragment = View | ViewArray +export type ViewFragment = View | ViewArray | undefined | null export abstract class Group extends Superview { @@ -499,7 +499,7 @@ export abstract class Group extends Superview { e.forEach(e => this.addInnerElement(e)) } else if (e instanceof View) { this.addChild(e) - } else { + } else if (!!e) { loge(`Not allowed to add ${typeof e}`) } } diff --git a/doric-js/src/ui/view.ts b/doric-js/src/ui/view.ts index da419336..08eb107f 100644 --- a/doric-js/src/ui/view.ts +++ b/doric-js/src/ui/view.ts @@ -504,7 +504,7 @@ export abstract class Superview extends View { export type ViewArray = View[] -export type ViewFragment = View | ViewArray +export type ViewFragment = View | ViewArray | undefined | null export abstract class Group extends Superview implements JSX.ElementChildrenAttribute { @@ -540,7 +540,7 @@ export abstract class Group extends Superview implements JSX.ElementChildrenAttr e.forEach(e => this.addInnerElement(e)) } else if (e instanceof View) { this.addChild(e) - } else { + } else if (!!e) { loge(`Not allowed to add ${typeof e}`) } } diff --git a/doric-web/dist/index.js b/doric-web/dist/index.js index a8fc94d9..5466700b 100644 --- a/doric-web/dist/index.js +++ b/doric-web/dist/index.js @@ -2180,7 +2180,7 @@ class Group extends Superview { else if (e instanceof View) { this.addChild(e); } - else { + else if (!!e) { loge(`Not allowed to add ${typeof e}`); } }