Переглянути джерело

Renamed `ALLOW` and `DISALLOW` to lower case.

Oskar Wrobel 9 роки тому
батько
коміт
8c4669d4b5

+ 5 - 5
packages/ckeditor5-engine/src/model/schema.js

@@ -115,12 +115,12 @@ export class SchemaItem {
 	 * Returns all paths of given type that were previously registered in the item.
 	 * Returns all paths of given type that were previously registered in the item.
 	 *
 	 *
 	 * @private
 	 * @private
-	 * @param {String} type Paths' type. Possible values are `ALLOW` or `DISALLOW`.
+	 * @param {String} type Paths' type. Possible values are `allow` or `disallow`.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be returned.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be returned.
 	 * @returns {Array} Paths registered in the item.
 	 * @returns {Array} Paths registered in the item.
 	 */
 	 */
 	_getPaths( type, attribute ) {
 	_getPaths( type, attribute ) {
-		const source = type === 'ALLOW' ? this._allowed : this._disallowed;
+		const source = type === 'allow' ? this._allowed : this._disallowed;
 		const paths = [];
 		const paths = [];
 
 
 		for ( let item of source ) {
 		for ( let item of source ) {
@@ -165,7 +165,7 @@ export class SchemaItem {
 	 * Checks whether this item has any registered path of given type that matches provided path.
 	 * Checks whether this item has any registered path of given type that matches provided path.
 	 *
 	 *
 	 * @protected
 	 * @protected
-	 * @param {String} type Paths' type. Possible values are `ALLOW` or `DISALLOW`.
+	 * @param {String} type Paths' type. Possible values are `allow` or `disallow`.
 	 * @param {Array.<String>} checkPath Path to check.
 	 * @param {Array.<String>} checkPath Path to check.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be checked.
 	 * @param {String} [attribute] If set, only paths registered for given attribute will be checked.
 	 * @returns {Boolean} `true` if item has any registered matching path, `false` otherwise.
 	 * @returns {Boolean} `true` if item has any registered matching path, `false` otherwise.
@@ -384,7 +384,7 @@ export default class Schema {
 		// If there is matching disallow path, this query is not valid with schema.
 		// If there is matching disallow path, this query is not valid with schema.
 		for ( let attribute of query.attributes ) {
 		for ( let attribute of query.attributes ) {
 			for ( let schemaItem of schemaItems ) {
 			for ( let schemaItem of schemaItems ) {
-				if ( schemaItem._hasMatchingPath( 'DISALLOW', path, attribute ) ) {
+				if ( schemaItem._hasMatchingPath( 'disallow', path, attribute ) ) {
 					return false;
 					return false;
 				}
 				}
 			}
 			}
@@ -400,7 +400,7 @@ export default class Schema {
 			let matched = false;
 			let matched = false;
 
 
 			for ( let schemaItem of schemaItems ) {
 			for ( let schemaItem of schemaItems ) {
-				if ( schemaItem._hasMatchingPath( 'ALLOW', path, attribute ) ) {
+				if ( schemaItem._hasMatchingPath( 'allow', path, attribute ) ) {
 					matched = true;
 					matched = true;
 					break;
 					break;
 				}
 				}

+ 19 - 19
packages/ckeditor5-engine/tests/model/schema/schemaitem.js

@@ -42,7 +42,7 @@ describe( 'allow', () => {
 		item.allow( path1 );
 		item.allow( path1 );
 		item.allow( path2 );
 		item.allow( path2 );
 
 
-		let paths = item._getPaths( 'ALLOW' );
+		let paths = item._getPaths( 'allow' );
 
 
 		expect( paths.length ).to.equal( 2 );
 		expect( paths.length ).to.equal( 2 );
 
 
@@ -58,8 +58,8 @@ describe( 'allow', () => {
 		item.allow( [ 'div' ] );
 		item.allow( [ 'div' ] );
 		item.allow( [ 'header' ], 'bold' );
 		item.allow( [ 'header' ], 'bold' );
 
 
-		let pathsWithNoAttribute = item._getPaths( 'ALLOW' );
-		let pathsWithBoldAttribute = item._getPaths( 'ALLOW', 'bold' );
+		let pathsWithNoAttribute = item._getPaths( 'allow' );
+		let pathsWithBoldAttribute = item._getPaths( 'allow', 'bold' );
 
 
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
@@ -78,7 +78,7 @@ describe( 'disallow', () => {
 		item.disallow( path1 );
 		item.disallow( path1 );
 		item.disallow( path2 );
 		item.disallow( path2 );
 
 
-		let paths = item._getPaths( 'DISALLOW' );
+		let paths = item._getPaths( 'disallow' );
 
 
 		expect( paths.length ).to.equal( 2 );
 		expect( paths.length ).to.equal( 2 );
 
 
@@ -94,8 +94,8 @@ describe( 'disallow', () => {
 		item.disallow( [ 'div' ] );
 		item.disallow( [ 'div' ] );
 		item.disallow( [ 'header' ], 'bold' );
 		item.disallow( [ 'header' ], 'bold' );
 
 
-		let pathsWithNoAttribute = item._getPaths( 'DISALLOW' );
-		let pathsWithBoldAttribute = item._getPaths( 'DISALLOW', 'bold' );
+		let pathsWithNoAttribute = item._getPaths( 'disallow' );
+		let pathsWithBoldAttribute = item._getPaths( 'disallow', 'bold' );
 
 
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute.length ).to.equal( 1 );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
 		expect( pathsWithNoAttribute[ 0 ] ).to.deep.equal( [ 'div' ] );
@@ -111,25 +111,25 @@ describe( '_hasMatchingPath', () => {
 		item.allow( [ 'div' , 'header' ] );
 		item.allow( [ 'div' , 'header' ] );
 		item.allow( [ 'image' ] );
 		item.allow( [ 'image' ] );
 
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div', 'header' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'header' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div', 'header', 'span' ] ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'div', 'header' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'header' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'div', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
 	} );
 	} );
 
 
 	it( 'should return false if there are no allowed paths that match query path', () => {
 	it( 'should return false if there are no allowed paths that match query path', () => {
 		item.allow( [ 'div', 'p' ] );
 		item.allow( [ 'div', 'p' ] );
 
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'p' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'div' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'p', 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'p' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'p', 'div' ] ) ).to.be.false;
 	} );
 	} );
 
 
 	it( 'should return true if there is at least one disallowed path that matches query path', () => {
 	it( 'should return true if there is at least one disallowed path that matches query path', () => {
 		item.allow( [ 'div', 'header' ] );
 		item.allow( [ 'div', 'header' ] );
 		item.disallow( [ 'p', 'header' ] );
 		item.disallow( [ 'p', 'header' ] );
 
 
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'p', 'header', 'span' ] ) ).to.be.true;
 	} );
 	} );
 
 
 	it( 'should use only paths that are registered for given attribute', () => {
 	it( 'should use only paths that are registered for given attribute', () => {
@@ -138,12 +138,12 @@ describe( '_hasMatchingPath', () => {
 		item.allow( [ 'header' ] );
 		item.allow( [ 'header' ] );
 		item.disallow( [ 'header' ], 'bold' );
 		item.disallow( [ 'header' ], 'bold' );
 
 
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div', 'p' ]  ) ).to.be.true;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'ALLOW', [ 'html', 'div' ], 'bold' ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div', 'p' ]  ) ).to.be.true;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'allow', [ 'html', 'div' ], 'bold' ) ).to.be.true;
 
 
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'header' ] ) ).to.be.false;
-		expect( item._hasMatchingPath( 'DISALLOW', [ 'html', 'div', 'p', 'header', 'span' ], 'bold' ) ).to.be.true;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'header' ] ) ).to.be.false;
+		expect( item._hasMatchingPath( 'disallow', [ 'html', 'div', 'p', 'header', 'span' ], 'bold' ) ).to.be.true;
 	} );
 	} );
 } );
 } );