Open peter-klaesson-stratsys opened 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');
});
Looks like we mixed up this pull-request with a different bug, issue #34
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!
34