mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: Fixed behat text selection rule, which broke some tests.
The behat rule for text selection wasn't working due to the JavaScript not executing properly. I have also updated the code to traverse all childNodes, which is important if you have text like this: <p>text1 <b>text2</b> text3</p> And you are trying to select 'text3'
This commit is contained in:
parent
5e29249593
commit
4f7c6ebcff
@ -184,17 +184,24 @@ var editor = jQuery('#$inputFieldId').entwine('ss').getEditor(),
|
|||||||
sel = editor.getInstance().selection,
|
sel = editor.getInstance().selection,
|
||||||
rng = document.createRange(),
|
rng = document.createRange(),
|
||||||
matched = false;
|
matched = false;
|
||||||
|
|
||||||
jQuery(doc).find('body *').each(function() {
|
jQuery(doc).find('body *').each(function() {
|
||||||
if(!matched && this.firstChild && this.firstChild.nodeValue && this.firstChild.nodeValue.match('$text')) {
|
if(!matched) {
|
||||||
rng.setStart(this.firstChild, this.firstChild.nodeValue.indexOf('$text'));
|
for(var i=0;i<this.childNodes.length;i++) {
|
||||||
rng.setEnd(this.firstChild, this.firstChild.nodeValue.indexOf('$text') + '$text'.length);
|
if(!matched && this.childNodes[i].nodeValue && this.childNodes[i].nodeValue.match('$text')) {
|
||||||
sel.setRng(rng);
|
rng.setStart(this.childNodes[i], this.childNodes[i].nodeValue.indexOf('$text'));
|
||||||
editor.getInstance().nodeChanged();
|
rng.setEnd(this.childNodes[i], this.childNodes[i].nodeValue.indexOf('$text') + '$text'.length);
|
||||||
matched = true;
|
sel.setRng(rng);
|
||||||
|
editor.getInstance().nodeChanged();
|
||||||
|
matched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JS;
|
JS;
|
||||||
$this->getSession()->evaluateScript($js);
|
|
||||||
|
$this->getSession()->executeScript($js);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user