mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
f1fc41b0e5
This is more likely to be correct, and a necessary step in case we ever want to move to Object.is. This keeps ise as an alias for is, and introduces is_loosely for the old behaviour.
21 lines
594 B
JavaScript
21 lines
594 B
JavaScript
function isSpellingCheckOk(aEditor, aMisspelledWords) {
|
|
var selcon = aEditor.selectionController;
|
|
var sel = selcon.getSelection(selcon.SELECTION_SPELLCHECK);
|
|
var numWords = sel.rangeCount;
|
|
|
|
is(numWords, aMisspelledWords.length, "Correct number of misspellings and words.");
|
|
|
|
if (numWords !== aMisspelledWords.length) {
|
|
return false;
|
|
}
|
|
|
|
for (var i = 0; i < numWords; ++i) {
|
|
var word = String(sel.getRangeAt(i));
|
|
is(word, aMisspelledWords[i], "Misspelling is what we think it is.");
|
|
if (word !== aMisspelledWords[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|