Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xlaoyu/enhanced-el-tree

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xlaoyu/enhanced-el-tree - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

build/webpack.test.conf.js

21

package.json
{
"name": "@xlaoyu/enhanced-el-tree",
"version": "1.0.0",
"version": "1.1.0",
"private": false,

@@ -9,4 +9,4 @@ "description": "enhanced element-ui's tree component",

"lint": "eslint src",
"build": "webpack --progress --config ./build/webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
"build": "webpack --progress -p --config ./build/webpack.config.js",
"test": "cross-env NODE_ENV=test karma start test/karma.conf.js --single-run"
},

@@ -33,2 +33,3 @@ "repository": {

"babel-loader": "^7.1.2",
"babel-plugin-istanbul": "^4.1.5",
"babel-plugin-syntax-jsx": "^6.18.0",

@@ -38,2 +39,4 @@ "babel-plugin-transform-vue-jsx": "^3.5.1",

"babel-preset-stage-2": "^6.24.1",
"chai": "^4.1.2",
"cross-env": "^5.1.3",
"css-loader": "^0.28.9",

@@ -45,2 +48,11 @@ "element-ui": "^2.1.0",

"eslint-plugin-vue": "^4.2.2",
"karma": "^2.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "^2.0.13",
"mocha": "^5.0.2",
"node-sass": "^4.7.2",

@@ -54,3 +66,4 @@ "sass-loader": "^6.0.6",

"webpack": "^3.11.0"
}
},
"dependencies": {}
}

@@ -171,6 +171,16 @@ import objectAssign from 'element-ui/src/utils/merge';

insertChild(child, index) {
insertChild(child, index, batch) {
if (!child) throw new Error('insertChild error: child is required.');
if (!(child instanceof Node)) {
if (!batch) {
const children = this.getChildren() || [];
if (children.indexOf(child.data) === -1) {
if (typeof index === 'undefined' || index < 0) {
children.push(child.data);
} else {
children.splice(index, 0, child.data);
}
}
}
objectAssign(child, {

@@ -212,2 +222,8 @@ parent: this,

removeChild(child) {
const children = this.getChildren() || [];
const dataIndex = children.indexOf(child.data);
if (dataIndex > -1) {
children.splice(dataIndex, 1);
}
const index = this.childNodes.indexOf(child);

@@ -268,3 +284,3 @@

array.forEach(item => {
this.insertChild(objectAssign({ data: item }, defaultProps));
this.insertChild(objectAssign({ data: item }, defaultProps), undefined, true);
});

@@ -351,2 +367,3 @@ }

getChildren() {
if (this.level === 0) return this.data;
// this is data

@@ -353,0 +370,0 @@ const data = this.data;

43

src/model/tree-store.js

@@ -68,5 +68,8 @@ import Node from './node';

const instanceChanged = newVal !== this.root.data;
this.root.setData(newVal);
if (instanceChanged) {
this.root.setData(newVal);
this._initDefaultCheckedNodes();
} else {
this.root.updateChildren();
}

@@ -76,4 +79,5 @@ }

getNode(data) {
if (data instanceof Node) return data;
const key = typeof data !== 'object' ? data : getNodeKey(this.key, data);
return this.nodesMap[key];
return this.nodesMap[key] || null;
}

@@ -161,3 +165,3 @@

childNodes.forEach(child => {
if ((!leafOnly && child.checked) || (leafOnly && child.isLeaf && child.checked)) {
if (child.checked && (!leafOnly || (leafOnly && child.isLeaf))) {
checkedNodes.push(child.data);

@@ -176,15 +180,28 @@ }

getCheckedKeys(leafOnly = false) {
const key = this.key;
const allNodes = this._getAllNodes();
const keys = [];
allNodes.forEach(node => {
if (!leafOnly || (leafOnly && node.isLeaf)) {
if (node.checked) {
keys.push((node.data || {})[key]);
return this.getCheckedNodes(leafOnly).map((data) => (data || {})[this.key]);
}
getHalfCheckedNodes() {
const nodes = [];
const traverse = function(node) {
const childNodes = node.root ? node.root.childNodes : node.childNodes;
childNodes.forEach((child) => {
if (child.indeterminate) {
nodes.push(child.data);
}
}
});
return keys;
traverse(child);
});
};
traverse(this);
return nodes;
}
getHalfCheckedKeys() {
return this.getHalfCheckedNodes().map((data) => (data || {})[this.key]);
}
_getAllNodes() {

@@ -191,0 +208,0 @@ const allNodes = [];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc