Skip to content

Commit

Permalink
Merge pull request #928 from Tencent/fix/color-picker-ssr
Browse files Browse the repository at this point in the history
fix: ssr render
  • Loading branch information
chaishi committed May 30, 2022
2 parents 848bd1d + 325eb88 commit a6ab0a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/color-picker/utils/click-outsider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentPublicInstance } from '@vue/composition-api';
import { VNode } from 'vue';
import { prefix } from '../../config';
import { on } from '../../utils/dom';
import { on, isServer } from '../../utils/dom';

type Handler = (...args: unknown[]) => unknown;

Expand All @@ -19,7 +19,7 @@ let startClick: MouseEvent;

let uid = 0;

if (window && window.document) {
if (!isServer && window.document) {
on(document, 'mousedown', (e: MouseEvent) => (startClick = e));
on(document, 'mouseup', (e: MouseEvent) => {
// eslint-disable-next-line no-restricted-syntax
Expand Down
4 changes: 2 additions & 2 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import isString from 'lodash/isString';
import { easeInOutCubic, EasingFunction } from './easing';
import { ScrollContainer, ScrollContainerElement } from '../common';

const isServer = Vue.prototype.$isServer || typeof window === 'undefined';
export const isServer = Vue.prototype.$isServer || typeof window === 'undefined';

const trim = (str: string): string => (str || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
export const trim = (str: string): string => (str || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');

export const on = ((): any => {
if (!isServer && document.addEventListener) {
Expand Down

0 comments on commit a6ab0a3

Please sign in to comment.