ソースを参照

Fix: Used the data-placeholder attribute instead of invalid placeholder to set the editor placeholder text (see ckeditor/ckeditor5#1517).

Aleksander Nowodzinski 6 年 前
コミット
00d9155614

+ 1 - 1
packages/ckeditor5-editor-classic/src/classiceditorui.js

@@ -169,7 +169,7 @@ export default class ClassicEditorUI 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( {

+ 4 - 4
packages/ckeditor5-editor-classic/tests/classiceditorui.js

@@ -126,10 +126,10 @@ describe( 'ClassicEditorUI', () => {
 					} );
 			} );
 
-			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 VirtualClassicTestEditor
 					.create( element, {
@@ -144,10 +144,10 @@ describe( 'ClassicEditorUI', () => {
 					} );
 			} );
 
-			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 VirtualClassicTestEditor
 					.create( element, {

+ 2 - 2
packages/ckeditor5-editor-classic/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>