private function LinkitDialogTest::getLinkAttributeFromEditor in Linkit 8.5
Gets an attribute of the first link in the ckeditor editor.
Parameters
string $attribute: The attribute name.
Return value
string|null The attribute, or null if the attribute is not found on the element.
1 call to LinkitDialogTest::getLinkAttributeFromEditor()
- LinkitDialogTest::testLinkDialog in tests/
src/ FunctionalJavascript/ LinkitDialogTest.php - Test the link dialog.
File
- tests/
src/ FunctionalJavascript/ LinkitDialogTest.php, line 310
Class
- LinkitDialogTest
- Tests the linkit alterations on the drupallink plugin.
Namespace
Drupal\Tests\linkit\FunctionalJavascriptCode
private function getLinkAttributeFromEditor($attribute) {
// We can't use $session->switchToIFrame() here, because the iframe does not
// have a name.
$javascript = <<<JS
(function(){
var iframes = document.getElementsByClassName('cke_wysiwyg_frame');
if (iframes.length) {
var doc = iframes[0].contentDocument || iframes[0].contentWindow.document;
var link = doc.getElementsByTagName('a')[0];
return link.getAttribute("{<span class="php-variable">$attribute</span>}");
}
})()
JS;
return $this
->getSession()
->evaluateScript($javascript);
}