<commit_before>'use strict';

/**
 * @license
 * (c) 2014 Cluster Labs, Inc. https://cluster.co/
 * License: MIT
 */

var util = skit.platform.util;
var zest = skit.thirdparty.zest;


var ELEMENT_NODE_TYPE = 1;


var ElementWrapper = function(element) {
  this.element = element;
};


ElementWrapper.prototype.children = function() {
  if (this.element.children) {
    return util.toArray(this.element.children);
  }

  return util.filter(this.element.childNodes, function(node) {
    return node.nodeType == ELEMENT_NODE_TYPE;
  });
};


ElementWrapper.prototype.parent = function() {
  if (this.element.parentNode && this.element.parentNode.nodeType == ELEMENT_NODE_TYPE) {
    return new ElementWrapper(this.element.parentNode);
  }
  return null;
};


ElementWrapper.prototype.matches = function(selector) {
  return zest.matches(this.element, selector);
};


ElementWrapper.prototype.find = function(selector) {
  return util.map(zest(selector, this.element), function(el) {
    return new ElementWrapper(el);
  });
};


ElementWrapper.prototype.get = function(selector) {
  var found = this.find(selector);
  return found.length ? found[0] : null;
};


ElementWrapper.prototype.$ = ElementWrapper.prototype.find;


ElementWrapper.prototype.first = function(selector) {
  var children = this.children();
  return children.length ? children[0] : null;
};


ElementWrapper.prototype.up = function(selector) {
  var current = this;
  while (current && !current.matches(selector)) {
    current = current.parent();
  }
  return current;
};


ElementWrapper.prototype.remove = function() {
  this.element.parentNode.removeChild(this.element);
};


ElementWrapper.prototype.classes = function() {
  return this.element.className.split(/\s+/);
};


ElementWrapper.prototype.hasClass = function(className) {
  var classes = this.classes();
  for (var i = 0; i < classes.length; i++) {
    if (classes[i] == className) {
      return true;
    }
  }
  return false;
};


ElementWrapper.prototype.addClass = function(className) {
  if (!this.hasClass(className)) {
    this.element.className = util.trim(this.element.className + ' ' + className);
  }
};


ElementWrapper.prototype.removeClass = function(classToRemove) {
  var classes = util.filter(this.classes(), function(className) {
    return className != classToRemove;
  });

  this.element.className = classes.join(' ');
};


ElementWrapper.prototype.toggleClass = function(className) {
  if (this.hasClass(className)) {
    this.removeClass(className);
  } else {
    this.addClass(className);
  }
};


ElementWrapper.prototype.getData = function(key) {
  if (this.el.dataset) {
    return this.el.dataset[util.camelCase(key)];
  }
  return this.el.getAttribute('data-' + key);
};


ElementWrapper.prototype.setData = function(key, value) {
  if (this.el.dataset) {
    return this.el.dataset[util.camelCase(key)] = value;
  }
  return this.el.setAttribute('data-' + key, value);
};


ElementWrapper.prototype.setText = function(value) {
  if (typeof this.el.innerText !== 'undefined') {
    this.el.innerText = value;
  } else {
    this.el.innerHTML = util.escapeHtml(value);
  }
};


ElementWrapper.prototype.getValue = function() {
  // TODO(Taylor): Implement for textareas.
  return this.element.value;
};


return ElementWrapper;<commit_msg>Fix existing properties dataset implementation.<commit_after>'use strict';

/**
 * @license
 * (c) 2014 Cluster Labs, Inc. https://cluster.co/
 * License: MIT
 */

var util = skit.platform.util;
var zest = skit.thirdparty.zest;


var ELEMENT_NODE_TYPE = 1;


var ElementWrapper = function(element) {
  this.element = element;
};


ElementWrapper.prototype.children = function() {
  if (this.element.children) {
    return util.toArray(this.element.children);
  }

  return util.filter(this.element.childNodes, function(node) {
    return node.nodeType == ELEMENT_NODE_TYPE;
  });
};


ElementWrapper.prototype.parent = function() {
  if (this.element.parentNode && this.element.parentNode.nodeType == ELEMENT_NODE_TYPE) {
    return new ElementWrapper(this.element.parentNode);
  }
  return null;
};


ElementWrapper.prototype.matches = function(selector) {
  return zest.matches(this.element, selector);
};


ElementWrapper.prototype.find = function(selector) {
  return util.map(zest(selector, this.element), function(el) {
    return new ElementWrapper(el);
  });
};


ElementWrapper.prototype.get = function(selector) {
  var found = this.find(selector);
  return found.length ? found[0] : null;
};


ElementWrapper.prototype.$ = ElementWrapper.prototype.find;


ElementWrapper.prototype.first = function(selector) {
  var children = this.children();
  return children.length ? children[0] : null;
};


ElementWrapper.prototype.up = function(selector) {
  var current = this;
  while (current && !current.matches(selector)) {
    current = current.parent();
  }
  return current;
};


ElementWrapper.prototype.remove = function() {
  this.element.parentNode.removeChild(this.element);
};


ElementWrapper.prototype.classes = function() {
  return this.element.className.split(/\s+/);
};


ElementWrapper.prototype.hasClass = function(className) {
  var classes = this.classes();
  for (var i = 0; i < classes.length; i++) {
    if (classes[i] == className) {
      return true;
    }
  }
  return false;
};


ElementWrapper.prototype.addClass = function(className) {
  if (!this.hasClass(className)) {
    this.element.className = util.trim(this.element.className + ' ' + className);
  }
};


ElementWrapper.prototype.removeClass = function(classToRemove) {
  var classes = util.filter(this.classes(), function(className) {
    return className != classToRemove;
  });

  this.element.className = classes.join(' ');
};


ElementWrapper.prototype.toggleClass = function(className) {
  if (this.hasClass(className)) {
    this.removeClass(className);
  } else {
    this.addClass(className);
  }
};


ElementWrapper.prototype.getData = function(key) {
  if (this.element.dataset) {
    return this.element.dataset[util.camelCase(key)];
  }
  return this.element.getAttribute('data-' + key);
};


ElementWrapper.prototype.setData = function(key, value) {
  if (this.element.dataset) {
    return this.element.dataset[util.camelCase(key)] = value;
  }
  return this.element.setAttribute('data-' + key, value);
};


ElementWrapper.prototype.setText = function(value) {
  if (typeof this.element.innerText !== 'undefined') {
    this.element.innerText = value;
  } else {
    this.element.innerHTML = util.escapeHtml(value);
  }
};


ElementWrapper.prototype.getValue = function() {
  // TODO(Taylor): Implement for textareas.
  return this.element.value;
};


return ElementWrapper;
{'fraction_non_alphanumeric': 0.14499476283106388, 'fraction_numerical': 0.0023941343707915607, 'mean_word_length': 4.149460708782743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1061034', 'n_tokens_mistral': 2091, 'n_tokens_neox': 2041, 'n_words': 377}