Tree: add currentNodeKey property declaration and fix test for currentNodeKey (#13197)

* Add currentNodeKey property declaration, fix test for currentNodeKey

* translate Chines doc
pull/13360/head
Anton Kuznetsov 2018-11-08 14:28:24 +03:00 committed by hetech
parent d1440c9608
commit 2b7fa617ae
5 changed files with 38 additions and 37 deletions

View File

@ -1181,6 +1181,7 @@ You can drag and drop Tree nodes by adding a `draggable` attribute.
| show-checkbox | whether node is selectable | boolean | — | false |
| check-strictly | whether checked state of a node not affects its father and child nodes when `show-checkbox` is `true` | boolean | — | false |
| default-checked-keys | array of keys of initially checked nodes | array | — | — |
| current-node-key | key of initially selected node | string, number | — | — |
| filter-node-method | this function will be executed on each node when use filter method. if return `false`, tree node will be hidden. | Function(value, data, node) | — | — |
| accordion | whether only one node among the same level can be expanded at one time | boolean | — | false |
| indent | horizontal indentation of nodes in adjacent levels in pixels | number | — | 16 |

View File

@ -1181,6 +1181,7 @@ Puede arrastrar y soltar nodos de Tree añadiendo un atributo `draggable` .
| show-checkbox | Si un nodo es seleccionable | boolean | — | false |
| check-strictly | El estado de seleccion de un nodo no afecta a sus padres o hijos, cuando `show-checkbox` es `true` | boolean | — | false |
| default-checked-keys | Array con claves de los nodos seleccionados inicialmente | array | — | — |
| current-node-key | key of initially selected node | string, number | — | — |
| filter-node-method | Esta función se ejecutará en cada nodo cuando se use el método filtrtar, si devuelve `false` el nodo se oculta | Function(value, data, node) | — | — |
| accordion | Si solo un nodo de cada nivel puede expandirse a la vez | boolean | — | false |
| indent | Indentación horizontal de los nodos en niveles adyacentes, en pixeles | number | — | 16 |

View File

@ -1200,6 +1200,7 @@
| show-checkbox | 节点是否可被选择 | boolean | — | false |
| check-strictly | 在显示复选框的情况下,是否严格的遵循父子不互相关联的做法,默认为 false | boolean | — | false |
| default-checked-keys | 默认勾选的节点的 key 的数组 | array | — | — |
| current-node-key | 当前选中的节点 | string, number | — | — |
| filter-node-method | 对树节点进行筛选时执行的方法,返回 true 表示这个节点可以显示,返回 false 则表示这个节点会被隐藏 | Function(value, data, node) | — | — |
| accordion | 是否每次只打开一个同级树节点展开 | boolean | — | false |
| indent | 相邻级节点间的水平缩进,单位为像素 | number | — | 16 |

View File

@ -94,6 +94,7 @@
},
defaultCheckedKeys: Array,
defaultExpandedKeys: Array,
currentNodeKey: [String, Number],
renderContent: Function,
showCheckbox: {
type: Boolean,

View File

@ -202,14 +202,11 @@ describe('Tree', () => {
});
});
it('current-node-key', done => {
vm = getTreeVm(':props="defaultProps" :current-node-key="1"');
const firstNode = document.querySelector('.el-tree-node');
firstNode.click();
vm.$nextTick(() => {
expect(firstNode.classList.contains('is-current')).to.true;
done();
});
it('current-node-key', () => {
vm = getTreeVm(':props="defaultProps" default-expand-all highlight-current node-key="id" :current-node-key="11"');
const currentNodeLabel = document.querySelector('.is-current .el-tree-node__label').textContent;
expect(currentNodeLabel).to.be.equal('二级 1-1');
});
it('defaultExpandAll', () => {