<commit_before>
var BackbonePolymerAttach = function(element, pathPrefix) {
  console.log('BackbonePolymerAttach', this, element, pathPrefix);

  var indexOf = this.indexOf.bind(this);

  var modelSetup = function(model) {
    this.listenTo(model, 'change', function(ev) {
      for (var attribute in ev.changed) {
        var ix = indexOf(model);
        var value = model.get(attribute);
        element.notifyPath(pathPrefix + '.models.' + ix + '.attributes.' + attribute, value);
      }
    });
  };

  var splicesObject = this.models;

  var addNotify = function(model) {
    var ix = indexOf(model);

    // https://www.polymer-project.org/1.0/docs/devguide/properties.html#array-observation
    var change = {keySplices:[], indexSplices:[]};
    change.keySplices.push({
      index: ix,
      removed: [],
      removedItems: [],
      added: [ix]
    });
    change.indexSplices.push({
      index: ix,
      addedCount: 1,
      removed: [],
      object: splicesObject,
      type: 'splice'
    });

    element.notifyPath(pathPrefix + '.models.splices', change);

    // remove this timeout and the rendered element goes blank
    window.setTimeout(function() {
      // TODO would it be possible to notify .* here?
      for (var attribute in model.attributes) {
        // we could reuse code with modelSetup here
        var value = model.get(attribute);
        element.notifyPath(pathPrefix + '.models.' + ix + '.attributes.' + attribute, value);
      }
    }, 1);
  };

  this.each(modelSetup.bind(this));
  this.on('add', addNotify.bind(this));<commit_msg>Seems to fix compatibility with Polymer 1.1.x<commit_after>
var BackbonePolymerAttach = function(element, pathPrefix) {
  console.log('BackbonePolymerAttach', this, element, pathPrefix);

  var indexOf = this.indexOf.bind(this);

  var modelSetup = function(model) {
    this.listenTo(model, 'change', function(ev) {
      for (var attribute in ev.changed) {
        var ix = indexOf(model);
        var value = model.get(attribute);
        element.notifyPath(pathPrefix + '.models.' + ix + '.attributes.' + attribute, value);
      }
    });
  };

  var splicesObject = this.models;

  var addNotify = function(model) {
    var ix = indexOf(model);

    // https://www.polymer-project.org/1.0/docs/devguide/properties.html#array-observation
    var change = {keySplices:[], indexSplices:[]};
    change.keySplices.push({
      index: ix,
      removed: [],
      removedItems: [],
      added: [ix]
    });
    change.indexSplices.push({
      index: ix,
      addedCount: 1,
      removed: [],
      object: splicesObject,
      type: 'splice',
      addedKeys: [ix]
    });

    element.notifyPath(pathPrefix + '.models.splices', change);

    // remove this timeout and the rendered element goes blank
    window.setTimeout(function() {
      // TODO would it be possible to notify .* here?
      for (var attribute in model.attributes) {
        // we could reuse code with modelSetup here
        var value = model.get(attribute);
        element.notifyPath(pathPrefix + '.models.' + ix + '.attributes.' + attribute, value);
      }
    }, 1);
  };

  this.each(modelSetup.bind(this));
  this.on('add', addNotify.bind(this));
{'fraction_non_alphanumeric': 0.14147709566843253, 'fraction_numerical': 0.0031162355874104083, 'mean_word_length': 2.7898465171192446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3068336', 'n_tokens_mistral': 1002, 'n_tokens_neox': 959, 'n_words': 231}