'use strict';

var Document = require('../..').Document;

function create(markup) {
	var d = new Document();
	d.documentElement.innerHTML = markup;
	return  d.documentElement.childNodes[0];
}

suite('Element', function() {
	test('#className', function() {
		var elem = create('<div class="a b c">');
		assert.equal(elem.className, 'a b c');
	});

	suite('innerHTML', function() {
		test('`ownerDocument` attribute', function() {
			var elem = create('<div>');
			elem.ownerDocument = {};

			elem.innerHTML = '<span></span>';

			assert.equal(elem.ownerDocument, elem.childNodes[0].ownerDocument);
		});

		test('removal of previous `childNodes`', function() {
			var elem = create('<div>');
			var children;

			elem.innerHTML = '<span></span><div></div>';
			children = elem.childNodes.slice();
			elem.innerHTML = '';

			assert.equal(children[0].parentNode, null);
			assert.equal(children[1].parentNode, null);
		});
	});
});

@@ -919,13 +919,905 @@
 %7D);%0A%09%7D);
+%0A%0A%09suite('#getElementsByTagName', function() %7B%0A%09%09test('nested elements', function() %7B%0A%09%09%09var div = create('%3Cdiv%3E');%0A%09%09%09var ps;%0A%09%09%09div.innerHTML = '%3Cdiv%3E%3Cp%3E%3C/p%3E%3C/div%3E%3Cul%3E%3Cli%3E%3Cp%3E%3C/p%3E%3C/li%3E%3C/ul%3E%3Cp%3E%3C/p%3E';%0A%0A%09%09%09ps = div.getElementsByTagName('p');%0A%0A%09%09%09assert.equal(ps.length, 3);%0A%09%09%09assert.equal(ps%5B0%5D, div.childNodes%5B0%5D.childNodes%5B0%5D);%0A%09%09%09assert.equal(ps%5B1%5D, div.childNodes%5B1%5D.childNodes%5B0%5D.childNodes%5B0%5D);%0A%09%09%09assert.equal(ps%5B2%5D, div.childNodes%5B2%5D);%0A%09%09%7D);%0A%0A%09%09test('case insensitivity', function() %7B%0A%09%09%09var div = create('%3Cdiv%3E');%0A%09%09%09var spans1, spans2;%0A%09%09%09div.innerHTML = '%3CsPaN%3E%3C/sPaN%3E';%0A%0A%09%09%09spans1 = div.getElementsByTagName('span');%0A%09%09%09spans2 = div.getElementsByTagName('SPAN');%0A%0A%09%09%09assert.equal(div.childNodes.length, 1);%0A%09%09%09assert.equal(spans1.length, 1);%0A%09%09%09assert.equal(spans1%5B0%5D, div.childNodes%5B0%5D);%0A%09%09%09assert.equal(spans2.length, 1);%0A%09%09%09assert.equal(spans2%5B0%5D, div.childNodes%5B0%5D);%0A%09%09%7D);%0A%09%7D);
 %0A%7D);%0A

Add tests for `Element#getElementsByTagName`