<commit_before>import * as avalon from 'avalon2';
import '../ms-checkbox';

let treeID = 0;
avalon.component('ms-tree', {
    template: require('./ms-tree.html'),
    defaults: {
        checkable: false,
        tree: [],
        expandedKeys: [],
        checkedKeys: [],
        indeterminatedKeys: [],
        $bufferedTree: {},
        root: true,
        renderSubTree: function (el) {
            return  el.children.length ?
                '<wbr :widget="{is:\'ms-tree\',$id:\'tree_' + (++treeID) + '\',checkable:@checkable,tree:el.children,checkedKeys:@checkedKeys,indeterminatedKeys:@indeterminatedKeys,handleCheck:@handleCheck,root:false}"/>' :
                ''
        },
        openSubTree: function (el) {
            if (this.isExpended(el)) {
                this.expandedKeys.remove(el.key);
            } else {
                this.expandedKeys.push(el.key);
            }
        },
        changeIcon: function (el) {
            if (!el.children.length) {
                return '';
            }
            return this.isExpended(el) ? 'fa-caret-down' : 'fa-caret-right';
        },
        isExpended(el) {
            return this.expandedKeys.contains(el.key);
        },
        isChecked(el) {
            return this.checkedKeys.contains(el.key);
        },
        isIndeterminated(el) {
            return this.indeterminatedKeys.contains(el.key);
        },
        onCheck: avalon.noop,
        onCheckInner: avalon.noop,
        handleCheck(el) {
            if (this.isChecked(el)) {
                this.checkedKeys.remove(el.key);
                travelForCheckChildren(el.children, this.checkedKeys, false);
            } else {
                this.checkedKeys.push(el.key);
                travelForCheckChildren(el.children, this.checkedKeys, true);
            }
            this.indeterminatedKeys.remove(el.key);
            influenceParent(this.$bufferedTree[el.key], this.checkedKeys, this.indeterminatedKeys);
            this.onCheck(this.checkedKeys.toJSON());
        },
        onInit() {
            if (this.root) {
                travelForBuffer(this.tree.toJSON(), this.$bufferedTree);
            }<commit_msg>解决 IE8 下传组件数组参数的改变不触发更新的问题<commit_after>import * as avalon from 'avalon2';
import '../ms-checkbox';

let treeID = 0;
avalon.component('ms-tree', {
    template: require('./ms-tree.html'),
    defaults: {
        checkable: false,
        tree: [],
        expandedKeys: [],
        checkedKeys: [],
        checkedKeysString: '',
        indeterminatedKeys: [],
        $bufferedTree: {},
        root: true,
        renderSubTree: function (el) {
            return  el.children.length ?
                '<wbr :widget="{is:\'ms-tree\',$id:\'tree_' + (++treeID) + '\',checkable:@checkable,tree:el.children,checkedKeysString:@checkedKeysString,indeterminatedKeys:@indeterminatedKeys,handleCheck:@handleCheck,root:false}"/>' :
                ''
        },
        openSubTree: function (el) {
            if (this.isExpended(el)) {
                this.expandedKeys.remove(el.key);
            } else {
                this.expandedKeys.push(el.key);
            }
        },
        changeIcon: function (el) {
            if (!el.children.length) {
                return '';
            }
            return this.isExpended(el) ? 'fa-caret-down' : 'fa-caret-right';
        },
        isExpended(el) {
            return this.expandedKeys.contains(el.key);
        },
        isChecked(el) {
            return this.checkedKeys.contains(el.key);
        },
        isIndeterminated(el) {
            return this.indeterminatedKeys.contains(el.key);
        },
        onCheck: avalon.noop,
        onCheckInner: avalon.noop,
        handleCheck(el) {
            if (this.isChecked(el)) {
                this.checkedKeys.remove(el.key);
                travelForCheckChildren(el.children, this.checkedKeys, false);
            } else {
                this.checkedKeys.push(el.key);
                travelForCheckChildren(el.children, this.checkedKeys, true);
            }
            this.indeterminatedKeys.remove(el.key);
            influenceParent(this.$bufferedTree[el.key], this.checkedKeys, this.indeterminatedKeys);
            this.checkedKeysString = this.checkedKeys.join(',');
            this.onCheck(this.checkedKeys.toJSON());
        },
        onInit() {
            if (this.root) {
                travelForBuffer(this.tree.toJSON(), this.$bufferedTree);
                this.checkedKeysString = this.checkedKeys.join(',');
            } else {
                this.$watch('checkedKeysString', v => {
                    this.checkedKeys = v.split(',');
                });
                this.$fire('checkedKeysString', this.checkedKeys.join(','));
            }
{'fraction_non_alphanumeric': 0.13952511031729356, 'fraction_numerical': 0.0010506408909434755, 'mean_word_length': 1.7967097532314924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2203085', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1370, 'n_words': 184}