mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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,
|
||||
rng = document.createRange(),
|
||||
matched = false;
|
||||
|
||||
jQuery(doc).find('body *').each(function() {
|
||||
if(!matched && this.firstChild && this.firstChild.nodeValue && this.firstChild.nodeValue.match('$text')) {
|
||||
rng.setStart(this.firstChild, this.firstChild.nodeValue.indexOf('$text'));
|
||||
rng.setEnd(this.firstChild, this.firstChild.nodeValue.indexOf('$text') + '$text'.length);
|
||||
sel.setRng(rng);
|
||||
editor.getInstance().nodeChanged();
|
||||
matched = true;
|
||||
if(!matched) {
|
||||
for(var i=0;i<this.childNodes.length;i++) {
|
||||
if(!matched && this.childNodes[i].nodeValue && this.childNodes[i].nodeValue.match('$text')) {
|
||||
rng.setStart(this.childNodes[i], this.childNodes[i].nodeValue.indexOf('$text'));
|
||||
rng.setEnd(this.childNodes[i], this.childNodes[i].nodeValue.indexOf('$text') + '$text'.length);
|
||||
sel.setRng(rng);
|
||||
editor.getInstance().nodeChanged();
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
JS;
|
||||
$this->getSession()->evaluateScript($js);
|
||||
|
||||
$this->getSession()->executeScript($js);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user