Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix: Used the data-placeholder attribute instead of invalid placehold…
Browse files Browse the repository at this point in the history
…er to set the editor placeholder text (see ckeditor/ckeditor5#1517).
  • Loading branch information
oleq committed Feb 11, 2019
1 parent 9b27ccc commit 1ca070e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ballooneditorui.js
Expand Up @@ -126,7 +126,7 @@ export default class BalloonEditorUI extends EditorUI {
const editingRoot = editingView.document.getRoot();

const placeholderText = editor.config.get( 'placeholder' ) ||
editor.sourceElement && editor.sourceElement.getAttribute( 'placeholder' );
editor.sourceElement && editor.sourceElement.dataset.placeholder;

if ( placeholderText ) {
enablePlaceholder( {
Expand Down
8 changes: 4 additions & 4 deletions tests/ballooneditorui.js
Expand Up @@ -131,10 +131,10 @@ describe( 'BalloonEditorUI', () => {
} );
} );

it( 'sets placeholder from "placeholder" attribute of a passed element', () => {
it( 'sets placeholder from the "data-placeholder" attribute of a passed element', () => {
const element = document.createElement( 'div' );

element.setAttribute( 'placeholder', 'placeholder-text' );
element.dataset.placeholder = 'placeholder-text';

return VirtualBalloonTestEditor
.create( element, {
Expand All @@ -149,10 +149,10 @@ describe( 'BalloonEditorUI', () => {
} );
} );

it( 'uses editor.config.placeholder rather than "placeholder" attribute of a passed element', () => {
it( 'uses editor.config.placeholder rather than the "data-placeholder" attribute of a passed element', () => {
const element = document.createElement( 'div' );

element.setAttribute( 'placeholder', 'placeholder-text' );
element.dataset.placeholder = 'placeholder-text';

return VirtualBalloonTestEditor
.create( element, {
Expand Down
4 changes: 2 additions & 2 deletions tests/manual/placeholder.html
@@ -1,5 +1,5 @@
<div id="editor-1" placeholder="Placeholder from the attribute">
<div id="editor-1" data-placeholder="Placeholder from the attribute">
<p>Remove this text to see the placeholder.</p>
</div>
<br />
<div id="editor-2" placeholder="Placeholder from the attribute"></div>
<div id="editor-2" data-placeholder="Placeholder from the attribute"></div>

0 comments on commit 1ca070e

Please sign in to comment.