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 df0a6ff commit 77a7ccc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/inlineeditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class InlineEditorUI 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/inlineeditorui.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ describe( 'InlineEditorUI', () => {
} );
} );

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 VirtualInlineTestEditor
.create( element, {
Expand All @@ -166,10 +166,10 @@ describe( 'InlineEditorUI', () => {
} );
} );

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 VirtualInlineTestEditor
.create( element, {
Expand Down
4 changes: 2 additions & 2 deletions tests/manual/placeholder.html
Original file line number Diff line number Diff line change
@@ -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 77a7ccc

Please sign in to comment.