Skip to content

Commit

Permalink
fix: eslint format
Browse files Browse the repository at this point in the history
  • Loading branch information
Lydanne committed Sep 22, 2020
1 parent 2b67296 commit 52d6d7a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/color-picker/src/components/picker-dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ref="hue"
:color="color"
vertical
style="float: right;"
style="float: right"
></hue-slider>
<sv-panel ref="sl" :color="color"></sv-panel>
</div>
Expand Down
20 changes: 10 additions & 10 deletions packages/tree/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
import { Tree } from './entity/Tree'
import ElTreeNode from './TreeNode.vue'
import { t } from 'element-ui/src/locale'
import { extractMethods } from './libs/util'
// import emitter from 'element-ui/src/mixins/emitter'
// import { addClass, removeClass } from 'element-ui/src/utils/dom'
import { extractMethods, isFunction } from './libs/util'
import {
reactive,
toRefs,
Expand Down Expand Up @@ -115,7 +114,7 @@ export default {
'update:expanded'
],
setup(props, { emit }) {
setup(props) {
const instance = getCurrentInstance()
const tree = new Tree(props.data, props.defaultNodeKey, {
Expand All @@ -137,7 +136,7 @@ export default {
const { handleKeydown } = useKeyDown()
const drag = useDrag(props, state)
const drag = useDrag(props)
onMounted(() => {
if (props.currentNodeKey) {
Expand Down Expand Up @@ -281,7 +280,7 @@ function useKeyDown() {
}
}
function useDrag(props, state) {
function useDrag(props) {
const instance = getCurrentInstance()
const { emit } = instance
Expand Down Expand Up @@ -324,11 +323,12 @@ function useDrag(props, state) {
}
// wrap in try catch to address IE's error when first param is 'text/plain'
try {
// setData is required for draggable to work in FireFox
// the content has to be '' so dragging a node out of the tree won't open a new tab in FireFox
// setData is required for draggable to work in FireFox
// the content has to be '' so dragging a node out of the tree won't open a new tab in FireFox
e &&
e.dataTransfer &&
isFunction(e.dataTransfer.setData) &&
e.dataTransfer.setData('text/plain', '')
} catch (_) {}
e.preventDefault()
emit('node-drag-enter', dragState.start, node, e)
Expand Down
2 changes: 1 addition & 1 deletion packages/tree/TreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
ElNodeContent
},
setup(props, { emit }) {
setup(props) {
const elTree = inject('elTree')
const onClickNode = (e) => {
!elTree.props.expandOnClickNode ||
Expand Down
2 changes: 1 addition & 1 deletion packages/tree/__tests__/entity/tree-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('TreeNode.js', () => {
const node112 = treeNode.findOne(112)
const node12 = treeNode.findOne(12)

treeNode.filter((node, parentNode, deep) => {
treeNode.filter((node) => {
return node === node111
})

Expand Down
6 changes: 1 addition & 5 deletions packages/tree/entity/Tree.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { TreeNode } from './TreeNode'
import {
nodeMap,
nodeEach,
transitionObjectKey
} from '../libs/util'
import { nodeMap, nodeEach, transitionObjectKey } from '../libs/util'

export class Tree {
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/tree/entity/TreeNode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable eqeqeq */
import { isGreatGrandfather } from '../libs/util'

const typeFlag = Symbol('TREE_NODE')
Expand Down Expand Up @@ -421,7 +420,7 @@ export class TreeNode {
* @param {TreeNode} target
* @param {string} relative top, bottom, inner
*/
isAllowMove(target, relative) {
isAllowMove(target) {
if (
target === this ||
target === this.parent ||
Expand Down
13 changes: 9 additions & 4 deletions packages/tree/libs/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ export function isArray(value) {
export function isObject(value) {
return value instanceof Object && !(value instanceof Array)
}
export function isFunction(value) {
return value instanceof Function
}
/**
* Deep traversal of the object
* @param {object} target
* @param {function} callback(cloneRawNode, rawNode, isLeaf)
*/
export function nodeMap(
target,
callback = (cloneRawNode, rawNode, isLeaf) => null,
{ childKey = 'children', mapChildKey = 'children' } = { /* TreeNode */ }
callback = () => null,
{ childKey = 'children', mapChildKey = 'children' } = {
/* TreeNode */
}
) {
const dfs = (node) => {
if (isObject(node) && !isArray(node[childKey])) {
const _cloneNode = { ...node };
const _cloneNode = { ...node }
return callback(_cloneNode, node, true)
}
const cloneNode = { ...node }
Expand Down Expand Up @@ -117,4 +122,4 @@ export const extractMethods = (obj, methods) => {
methodList[method] = obj[method].bind(obj)
})
return methodList
}
}

0 comments on commit 52d6d7a

Please sign in to comment.