<commit_before>'use strict';
var util = require('util');

// TODO: Talk with Felix about implementing a standards-compliant method
// upstream.
require(
	'CSSselect/node_modules/domutils/node_modules/domelementtype'
).isTag =
require(
	'dom-serializer/node_modules/domelementtype'
).isTag = function(elem) {
	return elem.nodeType === 1;
};
var render = require('dom-serializer');
var select = require('CSSselect');
var Node = require('./dom-node');

var Element = function(options) {
	Node.apply(this, arguments);
};

util.inherits(Element, Node);

Element.prototype.getElementsByTagName = function(tagName) {
	return select(tagName, this);
};
Element.prototype.getElementById = function(id) {
	return select.selectOne('#' + id, this) || null;
};
Element.prototype.querySelectorAll = function(selector) {
	return select(selector, this);
};
Object.defineProperty(Element.prototype, 'className', {
	get: function() {
		return this.attributes.class;
	},
	set: function(className) {
		return this.attributes.class = className;
	}
});

Object.defineProperty(Element.prototype, 'tagName', {
	get: function() {
		return this.nodeName;
	},
	set: function(tagName) {
		return this.nodeName = tagName;
	}
});

Element.prototype.getAttribute = function(name) {
	return this.attributes.getNamedItem(name);
};

Element.prototype.setAttribute = function(name, value) {
	return this.attributes.setNamedItem(name, value);
};

Element.prototype.removeAttribute = function(name) {
	return this.attributes.removeNamedItem(name);
};

Element.prototype.addEventListener = function() {};

Object.defineProperty(Element.prototype, 'innerHTML', {
	get: function() {
		return render(this.children, {
			normalizeWhitespace: false,
			xmlMode: false,
			decodeEntities: true
		});
	},
	set: function(str) {
		this.childNodes = require('./evaluate')(str);
		this.childNodes.forEach(function(child) {
			child.parentNode = this;
		}, this);
		return this.childNodes;
	}
});

module.exports = Element;<commit_msg>Implement `Element#outerHTML`<commit_after>'use strict';
var util = require('util');

// TODO: Talk with Felix about implementing a standards-compliant method
// upstream.
require(
	'CSSselect/node_modules/domutils/node_modules/domelementtype'
).isTag =
require(
	'dom-serializer/node_modules/domelementtype'
).isTag = function(elem) {
	return elem.nodeType === 1;
};
var render = require('dom-serializer');
var select = require('CSSselect');
var Node = require('./dom-node');

var Element = function(options) {
	Node.apply(this, arguments);
};

util.inherits(Element, Node);

Element.prototype.getElementsByTagName = function(tagName) {
	return select(tagName, this);
};
Element.prototype.getElementById = function(id) {
	return select.selectOne('#' + id, this) || null;
};
Element.prototype.querySelectorAll = function(selector) {
	return select(selector, this);
};
Object.defineProperty(Element.prototype, 'className', {
	get: function() {
		return this.attributes.class;
	},
	set: function(className) {
		return this.attributes.class = className;
	}
});

Object.defineProperty(Element.prototype, 'tagName', {
	get: function() {
		return this.nodeName;
	},
	set: function(tagName) {
		return this.nodeName = tagName;
	}
});

Element.prototype.getAttribute = function(name) {
	return this.attributes.getNamedItem(name);
};

Element.prototype.setAttribute = function(name, value) {
	return this.attributes.setNamedItem(name, value);
};

Element.prototype.removeAttribute = function(name) {
	return this.attributes.removeNamedItem(name);
};

Element.prototype.addEventListener = function() {};

Object.defineProperty(Element.prototype, 'innerHTML', {
	get: function() {
		return render(this.children, {
			normalizeWhitespace: false,
			xmlMode: false,
			decodeEntities: true
		});
	},
	set: function(str) {
		this.childNodes = require('./evaluate')(str);
		this.childNodes.forEach(function(child) {
			child.parentNode = this;
		}, this);
		return this.childNodes;
	}
});

// TODO: Throw error when Element is a document root node.
Object.defineProperty(Element.prototype, 'outerHTML', {
	get: function() {
		return render(this, {
			normalizeWhitespace: false,
			xmlMode: false,
			decodeEntities: true
		});
	},
	set: function(str) {
		var newNode = require('./evaluate')(str);
		var idx = this.parentNode.childNodes.indexOf(this);

		this.parentNode.childNodes[idx] = newNode;
		newNode.parentNode = this.parentNode;
		this.parentNode = null;

		return newNode;
	}
});

module.exports = Element;
{'fraction_non_alphanumeric': 0.14827201783723523, 'fraction_numerical': 0.0004459308807134894, 'mean_word_length': 5.204702627939143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '464818', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1397, 'n_words': 278}