Replace createTextNode with new Text().

Sky doesn't have this method (per spec).

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/879733002
This commit is contained in:
Elliott Sprehn 2015-01-26 15:12:19 -08:00
parent 150ee5f775
commit 69fb511131
9 changed files with 12 additions and 12 deletions

View File

@ -44,7 +44,7 @@ function createElement(tagName) {
function createText(text) {
texts++;
return document.createTextNode(text);
return new Text(text);
}
function createElements(root, depth) {

View File

@ -15,9 +15,9 @@ var content = document.getElementById('content');
var out = [];
for (var i = 0; i < 1000; i++) {
var div = document.createElement('div');
div.appendChild(document.createElement('span')).appendChild(document.createTextNode('foo'));
div.appendChild(document.createTextNode(' '));
div.appendChild(document.createElement('span')).appendChild(document.createTextNode('bar'));
div.appendChild(document.createElement('span')).appendChild(new Text('foo'));
div.appendChild(new Text(' '));
div.appendChild(document.createElement('span')).appendChild(new Text('bar'));
content.appendChild(div);
}

View File

@ -9,9 +9,9 @@ describe("height of an editable block", function() {
var elem = document.getElementById("test");
var originalHeight = elem.offsetHeight;
var d = elem.appendChild(document.createElement('div'));
d.appendChild(document.createTextNode('aaa'));
d.appendChild(new Text('aaa'));
d = elem.appendChild(document.createElement('div'));
d.appendChild(document.createTextNode('bbb'));
d.appendChild(new Text('bbb'));
var newHeight = elem.offsetHeight;
while (elem.firstChild) {

View File

@ -28,7 +28,7 @@ describe('MutationObserver', function() {
observers[6].observe(div, {characterData: true, subtree: true});
observers[8].observe(div, {attributes: true});
div.setAttribute('foo', 'bar');
div.appendChild(document.createTextNode('hello'));
div.appendChild(new Text('hello'));
div.firstChild.textContent = 'goodbye';
setTimeout(function() {
assert.deepEqual(order, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);

View File

@ -9,7 +9,7 @@ function mutationCallback(mutations, observer) {
var mutationObserver = new MutationObserver(mutationCallback);
var body = document.getElementById("body");
mutationObserver.observe(body, {childList: true});
body.appendChild(document.createTextNode("PASS. We didn't crash"));
body.appendChild(new Text("PASS. We didn't crash"));
</script>
</body>
</html>

View File

@ -7,7 +7,7 @@ describe('Non-relevant properties on mutation records should be null, except for
var observer = new MutationObserver(function() {});
it('on characterData records', function() {
var text = document.createTextNode('something');
var text = new Text('something');
observer.observe(text, {characterData: true});
text.data = 'something else';
var record = observer.takeRecords()[0];

View File

@ -41,7 +41,7 @@ describe('MutationObserver on character data', function() {
// ...observer.disconnect() should prevent further delivery of mutations.
assert.equal(mutations, null);
charDataNode = document.createTextNode('');
charDataNode = new Text('');
observer.observe(charDataNode, { characterData: true });
charDataNode.textContent = 'foo';
charDataNode.textContent = 'bar';

View File

@ -5,7 +5,7 @@
describe('Test MutationObserver.observe', function() {
it('should respect character data options', function() {
var observer = new MutationObserver(function() {});
var text = document.createTextNode('0');
var text = new Text('0');
observer.observe(text, {characterDataOldValue: true});
text.data = '1';

View File

@ -7,7 +7,7 @@ describe('MutationObservers', function() {
it('should handle shadow dom', function() {
function mutate(element) {
element.setAttribute('data-foo', 'bar');
element.insertBefore(document.createTextNode('hello'), element.firstChild);
element.insertBefore(new Text('hello'), element.firstChild);
element.firstChild.textContent = 'goodbye';
element.removeChild(element.firstChild);
}