Skip to content

Commit

Permalink
Remove editor#didReparse hook
Browse files Browse the repository at this point in the history
  • Loading branch information
bantic committed Jan 28, 2016
1 parent 34ab629 commit eda9a2b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
10 changes: 0 additions & 10 deletions src/js/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,6 @@ class Editor {
this.addCallback(CALLBACK_QUEUES.CURSOR_DID_CHANGE, callback);
}

/**
* @method didReparse
* @param {Function} callback This callback is called after any part of the
* post is reparsed
* @public
*/
didReparse(callback) {
this.addCallback(CALLBACK_QUEUES.DID_REPARSE, callback);
}

_setupListeners() {
ELEMENT_EVENTS.forEach(eventName => {
this.addEventListener(this.element, eventName,
Expand Down
32 changes: 1 addition & 31 deletions tests/acceptance/editor-reparse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { test, module } = Helpers;

let editor, editorElement;

module('Acceptance: editor: reparsing', {
module('Acceptance: Editor: Reparsing', {
beforeEach() {
editorElement = $('#editor')[0];
},
Expand All @@ -21,9 +21,6 @@ test('changing text node content causes reparse of section', (assert) => {
return post([markupSection('p', [marker('abc')])]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let section = editor.post.sections.head;
let node = section.markers.head.renderNode.element;

Expand All @@ -35,7 +32,6 @@ test('changing text node content causes reparse of section', (assert) => {
setTimeout(() => {
assert.equal(section.text, 'def', 'section reparsed correctly');
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -49,9 +45,6 @@ test('removing text node causes reparse of section', (assert) => {
return post([markupSection('p', [marker('abc'), marker('def')])]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let section = editor.post.sections.head;
let node = section.markers.head.renderNode.element;

Expand All @@ -63,7 +56,6 @@ test('removing text node causes reparse of section', (assert) => {
setTimeout(() => {
assert.equal(section.text, 'def', 'section reparsed correctly');
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -80,17 +72,13 @@ test('removing section node causes reparse of post', (assert) => {
]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let node = editor.post.sections.head.renderNode.element;
assert.equal(node.innerHTML, 'abc', 'precond - correct node');

node.parentNode.removeChild(node);

setTimeout(() => {
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -106,9 +94,6 @@ test('inserting styled span in section causes section reparse', (assert) => {
]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let node = editor.post.sections.head.renderNode.element;
assert.equal(node.innerHTML, 'abc', 'precond - correct node');

Expand All @@ -119,7 +104,6 @@ test('inserting styled span in section causes section reparse', (assert) => {

setTimeout(() => {
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -136,16 +120,12 @@ test('inserting new top-level node causes reparse of post', (assert) => {
return post([markupSection('p', [marker('abc')])]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let span = document.createElement('span');
span.appendChild(document.createTextNode('123'));
editorElement.appendChild(span);

setTimeout(() => {
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -159,16 +139,12 @@ test('inserting node into blank post causes reparse', (assert) => {
return post();
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let span = document.createElement('span');
span.appendChild(document.createTextNode('123'));
editorElement.appendChild(span);

setTimeout(() => {
assert.postIsSimilar(editor.post, expected);
assert.ok(reparsed, 'did reparse');
done();
});
});
Expand All @@ -190,25 +166,19 @@ test('after reparsing post, mutations still handled properly', (assert) => {
return post([markupSection('p', [marker('abc')])]);
});

let reparsed = false;
editor.didReparse(() => reparsed = true);

let span = document.createElement('span');
span.appendChild(document.createTextNode('123'));
editorElement.appendChild(span);

setTimeout(() => {
assert.postIsSimilar(editor.post, expected1);
assert.ok(reparsed, 'did reparse');
reparsed = false;

let node = editorElement.firstChild.firstChild;
assert.equal(node.textContent, 'abc', 'precond - correct node');

node.textContent = 'def';

setTimeout(() => {
assert.ok(reparsed, 'reparsed again');
assert.postIsSimilar(editor.post, expected2);

done();
Expand Down

0 comments on commit eda9a2b

Please sign in to comment.