Merge branch 'dev' into next

This commit is contained in:
chenjiahan 2020-09-07 20:41:50 +08:00
commit 7f87c57d12
8 changed files with 20 additions and 22 deletions

View File

@ -16,6 +16,12 @@ exports[`close-icon prop 1`] = `
</div> </div>
`; `;
exports[`closeable prop 1`] = `
<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom">
<div class="van-action-sheet__header">Title</div>
</div>
`;
exports[`color option 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button type="button" class="van-action-sheet__item" style="color: red;"><span class="van-action-sheet__name">Option</span></button></div>`; exports[`color option 1`] = `<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button type="button" class="van-action-sheet__item" style="color: red;"><span class="van-action-sheet__name">Option</span></button></div>`;
exports[`description prop 1`] = ` exports[`description prop 1`] = `

View File

@ -1,7 +1,7 @@
import { ref, watch, computed, nextTick } from 'vue'; import { ref, watch, computed, nextTick } from 'vue';
// Utils // Utils
import { createNamespace, isDef } from '../utils'; import { createNamespace } from '../utils';
import { raf, doubleRaf } from '../utils/dom/raf'; import { raf, doubleRaf } from '../utils/dom/raf';
// Composition // Composition
@ -31,9 +31,7 @@ export default createComponent({
const contentRef = ref(); const contentRef = ref();
const { parent, index } = useParent(COLLAPSE_KEY); const { parent, index } = useParent(COLLAPSE_KEY);
const currentName = computed(() => const currentName = computed(() => props.name ?? index.value);
isDef(props.name) ? props.name : index.value
);
const expanded = computed(() => { const expanded = computed(() => {
if (parent) { if (parent) {

View File

@ -1,5 +1,5 @@
// Utils // Utils
import { createNamespace, isDef } from '../utils'; import { createNamespace } from '../utils';
import { preventDefault } from '../utils/dom/event'; import { preventDefault } from '../utils/dom/event';
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant'; import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
import { pickerProps, DEFAULT_ITEM_HEIGHT } from './shared'; import { pickerProps, DEFAULT_ITEM_HEIGHT } from './shared';
@ -90,9 +90,7 @@ export default createComponent({
let cursor = { children: this.columns }; let cursor = { children: this.columns };
while (cursor && cursor.children) { while (cursor && cursor.children) {
const defaultIndex = isDef(cursor.defaultIndex) const defaultIndex = cursor.defaultIndex ?? +this.defaultIndex;
? cursor.defaultIndex
: +this.defaultIndex;
formatted.push({ formatted.push({
values: cursor.children, values: cursor.children,
@ -313,9 +311,7 @@ export default createComponent({
allowHtml={this.allowHtml} allowHtml={this.allowHtml}
className={item.className} className={item.className}
itemHeight={this.itemPxHeight} itemHeight={this.itemPxHeight}
defaultIndex={ defaultIndex={item.defaultIndex ?? +this.defaultIndex}
isDef(item.defaultIndex) ? item.defaultIndex : +this.defaultIndex
}
swipeDuration={this.swipeDuration} swipeDuration={this.swipeDuration}
visibleItemCount={this.visibleItemCount} visibleItemCount={this.visibleItemCount}
initialOptions={item.values} initialOptions={item.values}

View File

@ -1,5 +1,5 @@
import { ref, watch, computed, nextTick, reactive, onMounted } from 'vue'; import { ref, watch, computed, nextTick, reactive, onMounted } from 'vue';
import { createNamespace, isDef, addUnit } from '../utils'; import { createNamespace, addUnit } from '../utils';
const [createComponent, bem] = createNamespace('progress'); const [createComponent, bem] = createNamespace('progress');
@ -46,7 +46,7 @@ export default createComponent({
const renderPivot = () => { const renderPivot = () => {
const { rootWidth, pivotWidth } = state; const { rootWidth, pivotWidth } = state;
const { textColor, pivotText, pivotColor, percentage } = props; const { textColor, pivotText, pivotColor, percentage } = props;
const text = isDef(pivotText) ? pivotText : percentage + '%'; const text = pivotText ?? percentage + '%';
const show = props.showPivot && text; const show = props.showPivot && text;
if (show) { if (show) {

View File

@ -1,5 +1,5 @@
// Utils // Utils
import { createNamespace, isDef, pick } from '../utils'; import { createNamespace, pick } from '../utils';
// Components // Components
import Popup, { popupSharedProps } from '../popup'; import Popup, { popupSharedProps } from '../popup';
@ -102,7 +102,7 @@ export default createComponent({
}; };
const renderCancelText = () => { const renderCancelText = () => {
const text = isDef(props.cancelText) ? props.cancelText : t('cancel'); const text = props.cancelText ?? t('cancel');
if (text) { if (text) {
return ( return (
<button type="button" class={bem('cancel')} onClick={onCancel}> <button type="button" class={bem('cancel')} onClick={onCancel}>

View File

@ -82,9 +82,7 @@ export default createComponent({
], ],
data() { data() {
const defaultValue = isDef(this.modelValue) const defaultValue = this.modelValue ?? this.defaultValue;
? this.value
: this.defaultValue;
const value = this.format(defaultValue); const value = this.format(defaultValue);
if (!equal(value, this.modelValue)) { if (!equal(value, this.modelValue)) {

View File

@ -1,4 +1,4 @@
import { isDef, createNamespace } from '../utils'; import { createNamespace } from '../utils';
import { ChildrenMixin } from '../mixins/relation'; import { ChildrenMixin } from '../mixins/relation';
import { routeProps } from '../composition/use-route'; import { routeProps } from '../composition/use-route';
@ -25,7 +25,7 @@ export default createComponent({
computed: { computed: {
computedName() { computedName() {
return isDef(this.name) ? this.name : this.index; return this.name ?? this.index;
}, },
isActive() { isActive() {

View File

@ -6,7 +6,7 @@ export function noop() {}
export const inBrowser = typeof window !== 'undefined'; export const inBrowser = typeof window !== 'undefined';
export function isDef(val: unknown): boolean { export function isDef<T>(val: T): val is NonNullable<T> {
return val !== undefined && val !== null; return val !== undefined && val !== null;
} }
@ -28,7 +28,7 @@ export function get(object: any, path: string): any {
let result = object; let result = object;
keys.forEach((key) => { keys.forEach((key) => {
result = isDef(result[key]) ? result[key] : ''; result = result[key] ?? '';
}); });
return result; return result;