Parcourir la source

Internal: Updated schema use. See ckeditor/ckeditor5-engine#1234.

Piotrek Koszuliński il y a 7 ans
Parent
commit
33a527c32b
1 fichiers modifiés avec 8 ajouts et 10 suppressions
  1. 8 10
      packages/ckeditor5-link/tests/linkcommand.js

+ 8 - 10
packages/ckeditor5-link/tests/linkcommand.js

@@ -37,12 +37,11 @@ describe( 'LinkCommand', () => {
 		beforeEach( () => {
 			model.schema.register( 'x', { inheritAllFrom: '$block' } );
 
-			model.schema.on( 'checkAttribute', ( evt, args ) => {
-				if ( args[ 0 ].endsWith( 'x $text' ) && args[ 1 ] == 'linkHref' ) {
-					evt.stop();
-					evt.return = false;
+			model.schema.addAttributeCheck( ( ctx, attributeName ) => {
+				if ( ctx.endsWith( 'x $text' ) && attributeName == 'linkHref' ) {
+					return false;
 				}
-			}, { priority: 'high' } );
+			} );
 		} );
 
 		describe( 'when selection is collapsed', () => {
@@ -238,12 +237,11 @@ describe( 'LinkCommand', () => {
 			} );
 
 			it( 'should not insert text with `linkHref` attribute when is not allowed in parent', () => {
-				model.schema.on( 'checkAttribute', ( evt, args ) => {
-					if ( args[ 0 ].endsWith( 'p $text' ) && args[ 1 ] == 'linkHref' ) {
-						evt.stop();
-						evt.return = false;
+				model.schema.addAttributeCheck( ( ctx, attributeName ) => {
+					if ( ctx.endsWith( 'p $text' ) && attributeName == 'linkHref' ) {
+						return false;
 					}
-				}, { priority: 'high' } );
+				} );
 
 				setData( model, '<p>foo[]bar</p>' );