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

Commit

Permalink
Merge b99b7a0 into f0902fb
Browse files Browse the repository at this point in the history
  • Loading branch information
jodator committed Apr 3, 2020
2 parents f0902fb + b99b7a0 commit 34fd3b7
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 45 deletions.
11 changes: 6 additions & 5 deletions src/model/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ export default class Element extends Node {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type.replace( /^model:/, '' );

if ( !name ) {
return cutType == 'element' || cutType == this.name || super.is( type );
} else {
return cutType == 'element' && name == this.name;
return type === 'element' || type === 'model:element' ||
type === this.name || type === 'model:' + this.name ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'node' || type === 'model:node';
}

return name === this.name && ( type === 'element' || type === 'model:element' );
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/model/liveposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export default class LivePosition extends Position {
* @returns {Boolean}
*/
is( type ) {
return type == 'livePosition' || type == 'model:livePosition' || super.is( type );
return type == 'livePosition' || type == 'model:livePosition' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type == 'position' || type == 'model:position';
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/model/liverange.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default class LiveRange extends Range {
* @returns {Boolean}
*/
is( type ) {
return type == 'liveRange' || type == 'model:liveRange' || super.is( type );
return type == 'liveRange' || type == 'model:liveRange' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type == 'range' || type == 'model:range';
}

/**
Expand Down
11 changes: 1 addition & 10 deletions src/model/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';

// To check if component is loaded more than once.
import '@ckeditor/ckeditor5-utils/src/version';

Expand Down Expand Up @@ -432,7 +431,7 @@ export default class Node {
* @returns {Boolean}
*/
is( type ) {
return type == 'node' || type == 'model:node';
return type === 'node' || type === 'model:node';
}

/**
Expand Down Expand Up @@ -500,11 +499,3 @@ export default class Node {
this._attrs.clear();
}
}

/**
* The node's parent does not contain this node.
*
* This error may be thrown from corrupted trees.
*
* @error model-node-not-found-in-parent
*/
16 changes: 12 additions & 4 deletions src/model/rootelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ export default class RootElement extends Element {
* @returns {Boolean}
*/
is( type, name ) {
const cutType = type.replace( 'model:', '' );
if ( !name ) {
return cutType == 'rootElement' || super.is( type );
} else {
return ( cutType == 'rootElement' && name == this.name ) || super.is( type, name );
return type === 'rootElement' || type === 'model:rootElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'element' || type === 'model:element' ||
type === this.name || type === 'model:' + this.name ||
type === 'node' || type === 'model:node';
}

return name === this.name && (
type === 'rootElement' || type === 'model:rootElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'element' || type === 'model:element'
);
}

/**
Expand All @@ -105,3 +112,4 @@ export default class RootElement extends Element {
// @if CK_DEBUG_ENGINE // console.log( 'ModelRootElement: ' + this );
// @if CK_DEBUG_ENGINE // }
}

4 changes: 3 additions & 1 deletion src/model/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default class Text extends Node {
* @returns {Boolean}
*/
is( type ) {
return type == 'text' || type == 'model:text' || super.is( type );
return type === 'text' || type === 'model:text' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'node' || type === 'model:node';
}

/**
Expand Down
14 changes: 10 additions & 4 deletions src/view/attributeelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,18 @@ export default class AttributeElement extends Element {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type && type.replace( /^view:/, '' );

if ( !name ) {
return cutType == 'attributeElement' || super.is( type );
return type === 'attributeElement' || type === 'view:attributeElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'attributeElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'attributeElement' || type === 'view:attributeElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'element' || type === 'view:element'
);
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/view/containerelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ export default class ContainerElement extends Element {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type && type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'containerElement' || super.is( type );
return type === 'containerElement' || type === 'view:containerElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'containerElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'containerElement' || type === 'view:containerElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'element' || type === 'view:element'
);
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/view/editableelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ export default class EditableElement extends ContainerElement {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type && type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'editableElement' || super.is( type );
return type === 'editableElement' || type === 'view:editableElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'containerElement' || type === 'view:containerElement' ||
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'editableElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'editableElement' || type === 'view:editableElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'containerElement' || type === 'view:containerElement' ||
type === 'element' || type === 'view:element'
);
}
}

Expand Down
8 changes: 5 additions & 3 deletions src/view/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ export default class Element extends Node {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'element' || cutType == this.name || super.is( type );
return type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'node' || type === 'view:node';
} else {
return cutType == 'element' && name == this.name;
return name === this.name && ( type === 'element' || type === 'view:element' );
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/view/emptyelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ export default class EmptyElement extends Element {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'emptyElement' || super.is( type );
return type === 'emptyElement' || type === 'view:emptyElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'emptyElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'emptyElement' || type === 'view:emptyElement' ||
type === 'element' || type === 'view:element'
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/view/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export default class Node {
* @returns {Boolean}
*/
is( type ) {
return type == 'node' || type == 'view:node';
return type === 'node' || type === 'view:node';
}

/**
Expand Down
17 changes: 14 additions & 3 deletions src/view/rooteditableelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,22 @@ export default class RootEditableElement extends EditableElement {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'rootElement' || super.is( type );
return type === 'rootElement' || type === 'view:rootElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'editableElement' || type === 'view:editableElement' ||
type === 'containerElement' || type === 'view:containerElement' ||
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'rootElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'rootElement' || type === 'view:rootElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === 'editableElement' || type === 'view:editableElement' ||
type === 'containerElement' || type === 'view:containerElement' ||
type === 'element' || type === 'view:element'
);
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/view/uielement.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ export default class UIElement extends Element {
* @returns {Boolean}
*/
is( type, name = null ) {
const cutType = type.replace( /^view:/, '' );
if ( !name ) {
return cutType == 'uiElement' || super.is( type );
return type === 'uiElement' || type === 'view:uiElement' ||
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
type === this.name || type === 'view:' + this.name ||
type === 'element' || type === 'view:element' ||
type === 'node' || type === 'view:node';
} else {
return ( cutType == 'uiElement' && name == this.name ) || super.is( type, name );
return name === this.name && (
type === 'uiElement' || type === 'view:uiElement' ||
type === 'element' || type === 'view:element'
);
}
}

Expand Down

0 comments on commit 34fd3b7

Please sign in to comment.