<commit_before>var view  = require('../view'),
    utils = require('../utils'),
    fun   = require('../function'),
    dom   = require('../dom'),
    Base  = require('./base').Base;

/**
 * @class
 * @augments Base
 */
var Container = view.newClass('Container', Base, {

    _setup: function(initArgs) {
        // optimize: base's _setup is empty, so do not call it here.
        // Base.prototype._setup.call(this, initArgs);
        this._childViews = [];
    },

    destruct: function() {
        utils.invoke(this.childViews(), 'destruct');
        Base.prototype.destruct.call(this);
    },

    _layout: function() {
        utils.invoke(this.childViews(), 'layout');
        return this;
    },

    /**
     * Sets or retrieves view child view.
     * @param anything build can parse
     *
     * Note: if setting on view with child views, all child view will be removed
     */
    childViews: function(val, destruct/*=true*/) {
        if (val === undefined) return this._childViews;
        this.clear(destruct);
        require('../builder').build(val).forEach(function(child) {
            this.appendChild(child);
        }, this);
        return this;
    },<commit_msg>restore clear functionality for childViews<commit_after>var view  = require('../view'),
    utils = require('../utils'),
    fun   = require('../function'),
    dom   = require('../dom'),
    Base  = require('./base').Base;

/**
 * @class
 * @augments Base
 */
var Container = view.newClass('Container', Base, {

    _setup: function(initArgs) {
        // optimize: base's _setup is empty, so do not call it here.
        // Base.prototype._setup.call(this, initArgs);
        this._childViews = [];
    },

    destruct: function() {
        utils.invoke(this.childViews(), 'destruct');
        Base.prototype.destruct.call(this);
    },

    _layout: function() {
        utils.invoke(this.childViews(), 'layout');
        return this;
    },

    /**
     * Sets or retrieves view child view.
     * @param anything build can parse
     *
     * Note: if setting on view with child views, all child view will be removed
     */
    childViews: function(val, destruct/*=true*/) {
        if (val === undefined) return this._childViews;
        utils.forEach(this.childViews(), function(child) {
            this.removeChild(child);
            if (destruct !== false) { child.destruct(); }
        }, this);
        require('../builder').build(val).forEach(function(child) {
            this.appendChild(child);
        }, this);
        return this;
    },
{'fraction_non_alphanumeric': 0.15849352687328364, 'fraction_numerical': 0.0, 'mean_word_length': 2.294573643410853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7125568', 'n_tokens_mistral': 729, 'n_tokens_neox': 709, 'n_words': 179}