badsyntax / jquery-spellchecker

[not maintained] A lightweight jQuery plugin that can check the spelling of text within a form field or DOM tree.
http://jquery-spellchecker.badsyntax.co
MIT License
257 stars 113 forks source link

This pull request solves #34 #33

Open peter-klaesson-stratsys opened 11 years ago

peter-klaesson-stratsys commented 11 years ago

34

badsyntax commented 11 years ago

Am struggling a little bit to follow how this works. (Can you add some tests?) It looks like this only accommodates reverts to DOM trees within separate documents (eg docs within iframes). It would be super cool if we can revert changes to /any/ DOM tree (I guess similar to the approach in issue #27).

I want to be able to do this:

test('Reverting specific DOM trees', function() {

    var d1 = document.createElement('div');
    d1.innerHTML = 'test test';
    findAndReplaceDOMText(/test/ig, d1, 'div');

    var d2 = document.createElement('div');
    d2.innerHTML = 'test test test';
    findAndReplaceDOMText(/test/ig, d2, 'div');

    htmlEqual(d1.innerHTML, '<div>test</div> <div>test</div>');
    htmlEqual(d2.innerHTML, '<div>test</div> <div>test</div> <div>test</div>');

    findAndReplaceDOMText.revert(d1);
    findAndReplaceDOMText.revert(d2);

    htmlEqual(d1.innerHTML, 'test test');
    htmlEqual(d2.innerHTML, 'test test test');
});
johan-ludvigsson-stratsys commented 11 years ago

Looks like we mixed up this pull-request with a different bug, issue #34

badsyntax commented 11 years ago

Thanks for the update, it makes more sense now! The merge request looks like a good solution, but I want to spend some time reviewing before merging. Ideally I would also like this change to happen in https://github.com/padolsey/findAndReplaceDOMText as I don't want to make custom changes to this function within this project. Please bear with me!