<commit_before><!DOCTYPE html>
<!--
Copyright (c) 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/event.html">
<link rel="import" href="/tracing/ui/base/ui.html">

<script>
'use strict';

/**
 * @fileoverview Container that decorates its children.
 */
tr.exportTo('tr.ui.b', function() {
  /**
   * @constructor
   */
  var ContainerThatDecoratesItsChildren = tr.ui.b.define('div');

  ContainerThatDecoratesItsChildren.prototype = {
    __proto__: HTMLUnknownElement.prototype,

    decorate: function() {
      this.observer_ = new WebKitMutationObserver(this.didMutate_.bind(this));
      this.observer_.observe(this, { childList: true });

      // textContent is a variable on regular HTMLElements. However, we want to
      // hook and prevent writes to it.
      Object.defineProperty(
          this, 'textContent',
          { get: undefined, set: this.onSetTextContent_});
    },

    // TODO(polymer): Do we need to use Polymer.dom on these functions?
    appendChild: function(x) {
      Polymer.dom(HTMLUnknownElement.prototype).appendChild.call(this, x);
      this.didMutate_(this.observer_.takeRecords());
    },

    insertBefore: function(x, y) {
      HTMLUnknownElement.prototype.insertBefore.call(this, x, y);
      this.didMutate_(this.observer_.takeRecords());
    },

    removeChild: function(x) {
      HTMLUnknownElement.prototype.removeChild.call(this, x);
      this.didMutate_(this.observer_.takeRecords());
    },

    replaceChild: function(x, y) {
      HTMLUnknownElement.prototype.replaceChild.call(this, x, y);
      this.didMutate_(this.observer_.takeRecords());
    },

    onSetTextContent_: function(textContent) {
      if (textContent != '')
        throw new Error('textContent can only be set to \'\'.');
      this.clear();
    },

    clear: function() {
      while (this.lastChild)
        HTMLUnknownElement.prototype.removeChild.call(this, this.lastChild);<commit_msg>[polymer] Makes ContainerThatDecoratesItsChildren use HTMLDivElement<commit_after><!DOCTYPE html>
<!--
Copyright (c) 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/event.html">
<link rel="import" href="/tracing/ui/base/ui.html">

<script>
'use strict';

/**
 * @fileoverview Container that decorates its children.
 */
tr.exportTo('tr.ui.b', function() {
  /**
   * @constructor
   */
  var ContainerThatDecoratesItsChildren = tr.ui.b.define('div');

  ContainerThatDecoratesItsChildren.prototype = {
    __proto__: HTMLDivElement.prototype,

    decorate: function() {
      this.observer_ = new WebKitMutationObserver(this.didMutate_.bind(this));
      this.observer_.observe(this, { childList: true });

      // textContent is a variable on regular HTMLElements. However, we want to
      // hook and prevent writes to it.
      Object.defineProperty(
          this, 'textContent',
          { get: undefined, set: this.onSetTextContent_});
    },

    appendChild: function(x) {
      HTMLDivElement.prototype.appendChild.call(this, x);
      this.didMutate_(this.observer_.takeRecords());
    },

    insertBefore: function(x, y) {
      HTMLDivElement.prototype.insertBefore.call(this, x, y);
      this.didMutate_(this.observer_.takeRecords());
    },

    removeChild: function(x) {
      HTMLDivElement.prototype.removeChild.call(this, x);
      this.didMutate_(this.observer_.takeRecords());
    },

    replaceChild: function(x, y) {
      HTMLDivElement.prototype.replaceChild.call(this, x, y);
      this.didMutate_(this.observer_.takeRecords());
    },

    onSetTextContent_: function(textContent) {
      if (textContent != '')
        throw new Error('textContent can only be set to \'\'.');
      this.clear();
    },

    clear: function() {
      while (this.lastChild)
        HTMLDivElement.prototype.removeChild.call(this, this.lastChild);
{'fraction_non_alphanumeric': 0.132316773241515, 'fraction_numerical': 0.001967535661583866, 'mean_word_length': 3.382543103448276, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3750904', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1189, 'n_words': 271}