Skip to content

Commit

Permalink
fix: fix use assigned falsy value cannot be returned
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Jun 20, 2019
1 parent a4e349a commit e0129bc
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion components/alert/nz-alert.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class="ant-alert-close-icon"
(click)="closeAlert()">
<ng-template #closeDefaultTemplate>
<i nz-icon nzType="close" class="anticon-close"></i>
<i nz-icon nzType="close"></i>
</ng-template>
<ng-container *ngIf="nzCloseText; else closeDefaultTemplate">
<ng-container *nzStringTemplateOutlet="nzCloseText">{{ nzCloseText }}</ng-container>
Expand Down
2 changes: 1 addition & 1 deletion components/avatar/nz-avatar.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<i nz-icon *ngIf="nzIcon && hasIcon" [type]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i>
<i nz-icon *ngIf="nzIcon && hasIcon" [nzType]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i>
<img [src]="nzSrc" *ngIf="nzSrc && hasSrc" (error)="imgError()"/>
<span class="ant-avatar-string" #textEl [ngStyle]="textStyles" *ngIf="nzText && hasText">{{ nzText }}</span>
2 changes: 1 addition & 1 deletion components/cascader/nz-cascader-li.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<span
*ngIf="!option.isLeaf || option.children && option.children.length || option.loading"
class="ant-cascader-menu-item-expand-icon">
<i nz-icon [type]="option.loading ? 'loading' : 'right'"></i>
<i nz-icon [nzType]="option.loading ? 'loading' : 'right'"></i>
</span>
2 changes: 1 addition & 1 deletion components/collapse/nz-collapse-panel.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div role="tab" [attr.aria-expanded]="nzActive" class="ant-collapse-header" (click)="clickHeader()">
<ng-container *ngIf="nzShowArrow">
<ng-container *nzStringTemplateOutlet="nzExpandedIcon">
<i nz-icon [type]="nzExpandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="nzActive ? 90 : 0"></i>
<i nz-icon [nzType]="nzExpandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="nzActive ? 90 : 0"></i>
</ng-container>
</ng-container>
<ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
Expand Down
19 changes: 14 additions & 5 deletions components/core/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { Observable, Subject } from 'rxjs';
import { filter, mapTo } from 'rxjs/operators';
import { NzConfig, NZ_CONFIG } from './config';

const isDefined = function(value?: any): boolean {
return value !== undefined;
};

@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -79,11 +83,16 @@ export function WithConfig<T>(componentName: keyof NzConfig, innerDefaultValue?:
get(): T {
const originalValue =
originalDescriptor && originalDescriptor.get ? originalDescriptor.get.bind(this)() : this[privatePropName];
// To every component that supports global config should have a public property called `nzConfigService` injected.
const config = this.nzConfigService.config[componentName];
const configValue = config ? config[propName] : undefined;
const defaultValue = configValue !== undefined ? configValue : innerDefaultValue;
return originalValue || defaultValue;

if (isDefined(originalValue)) {
return originalValue;
}

const componentConfig = this.nzConfigService.config[componentName];
const configValue = isDefined(componentConfig) ? componentConfig[propName] : undefined;
const defaultValue = isDefined(configValue) ? configValue : innerDefaultValue;

return defaultValue;
},
set(value?: T): void {
if (originalDescriptor && originalDescriptor.set) {
Expand Down
2 changes: 1 addition & 1 deletion components/dropdown/nz-dropdown-button.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(click)="setVisibleStateWhen(true,'click')"
(mouseenter)="setVisibleStateWhen(true,'hover')"
(mouseleave)="setVisibleStateWhen(false,'hover')">
<ng-container *nzStringTemplateOutlet="nzIcon"><i nz-icon [type]="nzIcon"></i></ng-container>
<ng-container *nzStringTemplateOutlet="nzIcon"><i nz-icon [nzType]="nzIcon"></i></ng-container>
</button>
</div>
<ng-template
Expand Down
2 changes: 1 addition & 1 deletion components/form/demo/advanced-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
<button nz-button (click)="resetForm()">Clear</button>
<a style="margin-left:8px;font-size:12px;" (click)="toggleCollapse()">
Collapse
<i nz-icon [type]="isCollapse ? 'down' : 'up'"></i>
<i nz-icon [nzType]="isCollapse ? 'down' : 'up'"></i>
</a>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions components/input/nz-input-group.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<span class="ant-input-wrapper ant-input-group" *ngIf="isAddOn">
<span class="ant-input-group-addon" *ngIf="nzAddOnBefore || nzAddOnBeforeIcon">
<i nz-icon [type]="nzAddOnBeforeIcon" *ngIf="nzAddOnBeforeIcon"></i>
<i nz-icon [nzType]="nzAddOnBeforeIcon" *ngIf="nzAddOnBeforeIcon"></i>
<ng-container *nzStringTemplateOutlet="nzAddOnBefore">{{ nzAddOnBefore }}</ng-container>
</span>
<ng-template [ngIf]="!isAffix" *ngTemplateOutlet="contentTemplate"></ng-template>
<span class="ant-input-affix-wrapper" [class.ant-input-affix-wrapper-sm]="isSmall" [class.ant-input-affix-wrapper-lg]="isLarge" *ngIf="isAffix">
<ng-template *ngTemplateOutlet="affixTemplate"></ng-template>
</span>
<span class="ant-input-group-addon" *ngIf="nzAddOnAfter || nzAddOnAfterIcon">
<i nz-icon [type]="nzAddOnAfterIcon" *ngIf="nzAddOnAfterIcon"></i>
<i nz-icon [nzType]="nzAddOnAfterIcon" *ngIf="nzAddOnAfterIcon"></i>
<ng-container *nzStringTemplateOutlet="nzAddOnAfter">{{ nzAddOnAfter }}</ng-container>
</span>
</span>
Expand All @@ -18,12 +18,12 @@
<ng-template #affixTemplate>
<span class="ant-input-prefix" *ngIf="nzPrefix || nzPrefixIcon">
<!-- TODO: should have a class to set its color, cc: antd-->
<i nz-icon [type]="nzPrefixIcon" *ngIf="nzPrefixIcon" style="color: rgba(0, 0, 0, 0.25)"></i>
<i nz-icon [nzType]="nzPrefixIcon" *ngIf="nzPrefixIcon" style="color: rgba(0, 0, 0, 0.25)"></i>
<ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>
</span>
<ng-template *ngTemplateOutlet="contentTemplate"></ng-template>
<span class="ant-input-suffix" *ngIf="nzSuffix || nzSuffixIcon">
<i nz-icon [type]="nzSuffixIcon" *ngIf="nzSuffixIcon"></i>
<i nz-icon [nzType]="nzSuffixIcon" *ngIf="nzSuffixIcon"></i>
<ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>
</span>
</ng-template>
Expand Down
4 changes: 2 additions & 2 deletions components/layout/nz-sider.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<ng-template [ngTemplateOutlet]="nzTrigger"></ng-template>
</div>
<ng-template #defaultTrigger>
<i nz-icon [type]="nzCollapsed ? 'right' : 'left'" *ngIf="!nzReverseArrow"></i>
<i nz-icon [type]="nzCollapsed ? 'left' : 'right'" *ngIf="nzReverseArrow"></i>
<i nz-icon [nzType]="nzCollapsed ? 'right' : 'left'" *ngIf="!nzReverseArrow"></i>
<i nz-icon [nzType]="nzCollapsed ? 'left' : 'right'" *ngIf="nzReverseArrow"></i>
</ng-template>
<ng-template #zeroTrigger>
<i nz-icon nzType="bars"></i>
Expand Down
2 changes: 1 addition & 1 deletion components/menu/demo/inline-collapsed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Component } from '@angular/core';
template: `
<div style="width: 240px;">
<button nz-button [nzType]="'primary'" (click)="toggleCollapsed()" style="margin-bottom: 10px;">
<i nz-icon [type]="isCollapsed ? 'menu-unfold' : 'menu-fold'"></i>
<i nz-icon [nzType]="isCollapsed ? 'menu-unfold' : 'menu-fold'"></i>
</button>
<ul nz-menu [nzMode]="'inline'" nzTheme="dark" [nzInlineCollapsed]="isCollapsed">
<li nz-menu-item nz-tooltip nzPlacement="right" [nzTitle]="isCollapsed ? 'Navigation One' : ''">
Expand Down
4 changes: 2 additions & 2 deletions components/menu/demo/recursive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Component } from '@angular/core';
[nzSelected]="menu.selected"
>
<span title>
<i nz-icon [type]="menu.icon" *ngIf="menu.icon"></i>
<i nz-icon [nzType]="menu.icon" *ngIf="menu.icon"></i>
<span>{{ menu.title }}</span>
</span>
</li>
Expand All @@ -27,7 +27,7 @@ import { Component } from '@angular/core';
[nzDisabled]="menu.disabled"
>
<span title>
<i nz-icon [type]="menu.icon" *ngIf="menu.icon"></i>
<i nz-icon [nzType]="menu.icon" *ngIf="menu.icon"></i>
<span>{{ menu.title }}</span>
</span>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion components/modal/nz-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<div class="ant-modal-body" [ngStyle]="nzBodyStyle">
<div class="ant-modal-confirm-body-wrapper">
<div class="ant-modal-confirm-body">
<i nz-icon [type]="nzIconType"></i>
<i nz-icon [nzType]="nzIconType"></i>
<span class="ant-modal-confirm-title">
<ng-container [ngSwitch]="true">
<ng-container *ngSwitchCase="isTemplateRef(nzTitle)" [ngTemplateOutlet]="nzTitle"></ng-container>
Expand Down
2 changes: 1 addition & 1 deletion components/page-header/nz-page-header.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ng-content select="nz-breadcrumb[nz-page-header-breadcrumb]"></ng-content>

<div *ngIf="nzBackIcon !== null" (click)="onBack()" class="ant-page-header-back-icon">
<i *ngIf="isStringBackIcon" nz-icon [type]="nzBackIcon ? nzBackIcon : 'arrow-left'" theme="outline"></i>
<i *ngIf="isStringBackIcon" nz-icon [nzType]="nzBackIcon ? nzBackIcon : 'arrow-left'" theme="outline"></i>
<ng-container *ngIf="isTemplateRefBackIcon" [ngTemplateOutlet]="nzBackIcon"></ng-container>
<nz-divider nzType="vertical"></nz-divider>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/rate/nz-rate-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

<ng-template #defaultCharacter>
<i nz-icon
type="star"
theme="fill"></i>
nzType="star"
nzTheme="fill"></i>
</ng-template>
2 changes: 1 addition & 1 deletion components/steps/nz-step.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="ant-steps-icon" *ngIf="(nzStatus === 'process' || nzStatus === 'wait') && !nzIcon">{{ index + 1 }}</span>
<span class="ant-steps-icon" *ngIf="nzIcon">
<ng-container *ngIf="isIconString; else iconTemplate">
<i nz-icon [type]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i>
<i nz-icon [nzType]="!oldAPIIcon && nzIcon" [ngClass]="oldAPIIcon && nzIcon"></i>
</ng-container>
<ng-template #iconTemplate>
<ng-template [ngTemplateOutlet]="nzIcon"></ng-template>
Expand Down
2 changes: 1 addition & 1 deletion components/tabs/demo/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Component } from '@angular/core';
template: `
<nz-tabset>
<nz-tab *ngFor="let tab of tabs" [nzTitle]="titleTemplate">
<ng-template #titleTemplate> <i nz-icon [type]="tab.icon"></i>{{ tab.name }} </ng-template>
<ng-template #titleTemplate> <i nz-icon [nzType]="tab.icon"></i>{{ tab.name }} </ng-template>
{{ tab.name }}
</nz-tab>
</nz-tabset>
Expand Down
4 changes: 2 additions & 2 deletions components/tabs/nz-tabs-nav.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
[class.ant-tabs-tab-btn-disabled]="disableScrollBefore"
[class.ant-tabs-tab-arrow-show]="showPaginationControls">
<span class="ant-tabs-tab-prev-icon">
<i nz-icon [type]="nzPositionMode === 'horizontal' ? 'left' : 'up'" class="ant-tabs-tab-prev-icon-target"></i>
<i nz-icon [nzType]="nzPositionMode === 'horizontal' ? 'left' : 'up'" class="ant-tabs-tab-prev-icon-target"></i>
</span>
</span>
<span class="ant-tabs-tab-next"
(click)="scrollHeader('after')"
[class.ant-tabs-tab-btn-disabled]="disableScrollAfter"
[class.ant-tabs-tab-arrow-show]="showPaginationControls">
<span class="ant-tabs-tab-next-icon">
<i nz-icon [type]="nzPositionMode === 'horizontal' ? 'right' : 'down'" class="ant-tabs-tab-next-icon-target"></i>
<i nz-icon [nzType]="nzPositionMode === 'horizontal' ? 'right' : 'down'" class="ant-tabs-tab-next-icon-target"></i>
</span>
</span>
<div class="ant-tabs-nav-wrap">
Expand Down
2 changes: 1 addition & 1 deletion components/tree-select/demo/customized-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Component } from '@angular/core';
>
<ng-template #nzTreeTemplate let-node>
<span class="ant-tree-node-content-wrapper" [class.ant-tree-node-selected]="node.isSelected">
<span> <i nz-icon [type]="node.isExpanded ? 'folder-open' : 'folder'"></i> {{ node.title }} </span>
<span> <i nz-icon [nzType]="node.isExpanded ? 'folder-open' : 'folder'"></i> {{ node.title }} </span>
</span>
</ng-template>
</nz-tree-select>
Expand Down
2 changes: 1 addition & 1 deletion components/tree/demo/customized-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Component, OnInit } from '@angular/core';
template: `
<nz-tree [nzData]="nodes" nzShowIcon [nzExpandedIcon]="expandedIconTpl">
<ng-template #expandedIconTpl let-node>
<i nz-icon [type]="node.origin.icon" class="ant-tree-switcher-icon"></i>
<i nz-icon [nzType]="node.origin.icon" class="ant-tree-switcher-icon"></i>
</ng-template>
</nz-tree>
<nz-tree [nzData]="nodes" nzShowIcon [nzExpandedIcon]="mutiExpandedIconTpl">
Expand Down
2 changes: 1 addition & 1 deletion components/tree/demo/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { NzDropdownContextComponent, NzDropdownService, NzFormatEmitEvent, NzTre
<ng-template #nzTreeTemplate let-node>
<span class="custom-node" [class.active]="activedNode?.key === node.key">
<span *ngIf="!node.isLeaf" (contextmenu)="contextMenu($event, contextTemplate)">
<i nz-icon [type]="node.isExpanded ? 'folder-open' : 'folder'" (click)="openFolder(node)"></i>
<i nz-icon [nzType]="node.isExpanded ? 'folder-open' : 'folder'" (click)="openFolder(node)"></i>
<span class="folder-name">{{ node.title }}</span>
<span class="folder-desc">created by {{ node?.origin?.author | lowercase }}</span>
</span>
Expand Down
2 changes: 1 addition & 1 deletion components/tree/nz-tree-node.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[ngTemplateOutletContext]="{ $implicit: nzTreeNode }">
</ng-template>
<ng-container *ngIf="!isTemplateRef(nzExpandedIcon)">
<i *ngIf="isShowLineIcon" nz-icon [type]="isSwitcherOpen ? 'minus-square' : 'plus-square'" class="ant-tree-switcher-line-icon"></i>
<i *ngIf="isShowLineIcon" nz-icon [nzType]="isSwitcherOpen ? 'minus-square' : 'plus-square'" class="ant-tree-switcher-line-icon"></i>
<i *ngIf="!isShowLineIcon" nz-icon nzType="file" class="ant-tree-switcher-line-icon"></i>
</ng-container>
</ng-container>
Expand Down
2 changes: 1 addition & 1 deletion components/tree/nz-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ export class NzTestTreeOlderComponent implements OnInit {
template: `
<nz-tree #treeComponent [nzData]="nodes" nzShowIcon="true" [nzExpandedIcon]="expandedIconTpl">
<ng-template #expandedIconTpl let-node>
<i nz-icon [type]="'arrow-down'" class="ant-tree-switcher-icon"></i>
<i nz-icon [nzType]="'arrow-down'" class="ant-tree-switcher-icon"></i>
</ng-template>
</nz-tree>
`
Expand Down
14 changes: 6 additions & 8 deletions scripts/site/_site/doc/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,12 @@ <h2>
<span> - </span><span>{{language==='zh'?'企业级 Node 开发框架':'Enterprise Node Framework'}}</span>
</div>
<div style="margin-top: 20px;">
<nz-popover [nzTrigger]="'click'" nzOverlayClassName="theme-color-content">
<div class="theme-color" nz-popover>
<div class="theme-color-value" [ngStyle]="{'background': color}"></div>
</div>
<ng-template #nzTemplate>
<color-sketch [color]="color" (onChangeComplete)="changeColor($event)"></color-sketch>
</ng-template>
</nz-popover>
<div class="theme-color" nz-popover nzTrigger="click" [nzContent]="nzTemplate" nzOverlayClassName="theme-color-content">
<div class="theme-color-value" [ngStyle]="{'background': color}"></div>
</div>
<ng-template #nzTemplate>
<color-sketch [color]="color" (onChangeComplete)="changeColor($event)"></color-sketch>
</ng-template>
</div>
</div>
</div>
Expand Down

0 comments on commit e0129bc

Please sign in to comment.