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

Commit

Permalink
Removed invalid getters and improved docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Piechaczek committed Mar 29, 2018
1 parent ff6d8de commit f61cc3e
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/conversion/viewconsumable.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export default class ViewConsumable {
* @param {module:engine/view/element~Element|module:engine/view/text~Text|module:engine/view/documentfragment~DocumentFragment} element
* @param {Object} [consumables] Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
* @param {Boolean} consumables.name If set to true element's name will be included.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.class Class name or array of class names.
* @param {String|Array.<String>} consumables.style Style name or array of style names.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.classes Class name or array of class names.
* @param {String|Array.<String>} consumables.styles Style name or array of style names.
*/
add( element, consumables ) {
let elementConsumables;
Expand Down Expand Up @@ -120,9 +120,9 @@ export default class ViewConsumable {
* @param {module:engine/view/element~Element|module:engine/view/text~Text|module:engine/view/documentfragment~DocumentFragment} element
* @param {Object} [consumables] Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
* @param {Boolean} consumables.name If set to true element's name will be included.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.class Class name or array of class names.
* @param {String|Array.<String>} consumables.style Style name or array of style names.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.classes Class name or array of class names.
* @param {String|Array.<String>} consumables.styles Style name or array of style names.
* @returns {Boolean|null} Returns `true` when all items included in method's call can be consumed. Returns `false`
* when first already consumed item is found and `null` when first non-consumable item is found.
*/
Expand Down Expand Up @@ -164,9 +164,9 @@ export default class ViewConsumable {
* @param {module:engine/view/element~Element|module:engine/view/text~Text|module:engine/view/documentfragment~DocumentFragment} element
* @param {Object} [consumables] Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
* @param {Boolean} consumables.name If set to true element's name will be included.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.class Class name or array of class names.
* @param {String|Array.<String>} consumables.style Style name or array of style names.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.classes Class name or array of class names.
* @param {String|Array.<String>} consumables.styles Style name or array of style names.
* @returns {Boolean} Returns `true` when all items included in method's call can be consumed,
* otherwise returns `false`.
*/
Expand Down Expand Up @@ -210,9 +210,9 @@ export default class ViewConsumable {
* @param {module:engine/view/element~Element|module:engine/view/text~Text|module:engine/view/documentfragment~DocumentFragment} element
* @param {Object} [consumables] Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
* @param {Boolean} consumables.name If set to true element's name will be included.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.class Class name or array of class names.
* @param {String|Array.<String>} consumables.style Style name or array of style names.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names.
* @param {String|Array.<String>} consumables.classes Class name or array of class names.
* @param {String|Array.<String>} consumables.styles Style name or array of style names.
*/
revert( element, consumables ) {
const elementConsumables = this._consumables.get( element );
Expand Down Expand Up @@ -337,13 +337,7 @@ class ViewElementConsumables {
this._consumables = {
attributes: new Map(),
styles: new Map(),
get style() {
return this.styles;
},
classes: new Map(),
get class() {
return this.classes;
}
classes: new Map()
};
}

Expand All @@ -364,9 +358,9 @@ class ViewElementConsumables {
*
* @param {Object} consumables Object describing which parts of the element can be consumed.
* @param {Boolean} consumables.name If set to `true` element's name will be added as consumable.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names to add as consumable.
* @param {String|Array.<String>} consumables.class Class name or array of class names to add as consumable.
* @param {String|Array.<String>} consumables.style Style name or array of style names to add as consumable.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names to add as consumable.
* @param {String|Array.<String>} consumables.classes Class name or array of class names to add as consumable.
* @param {String|Array.<String>} consumables.styles Style name or array of style names to add as consumable.
*/
add( consumables ) {
if ( consumables.name ) {
Expand Down Expand Up @@ -394,9 +388,9 @@ class ViewElementConsumables {
*
* @param {Object} consumables Object describing which parts of the element should be tested.
* @param {Boolean} consumables.name If set to `true` element's name will be tested.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names to test.
* @param {String|Array.<String>} consumables.class Class name or array of class names to test.
* @param {String|Array.<String>} consumables.style Style name or array of style names to test.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names to test.
* @param {String|Array.<String>} consumables.classes Class name or array of class names to test.
* @param {String|Array.<String>} consumables.styles Style name or array of style names to test.
* @returns {Boolean|null} `true` when all tested items can be consumed, `null` when even one of the items
* was never marked for consumption and `false` when even one of the items was already consumed.
*/
Expand Down Expand Up @@ -434,9 +428,9 @@ class ViewElementConsumables {
*
* @param {Object} consumables Object describing which parts of the element should be consumed.
* @param {Boolean} consumables.name If set to `true` element's name will be consumed.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names to consume.
* @param {String|Array.<String>} consumables.class Class name or array of class names to consume.
* @param {String|Array.<String>} consumables.style Style name or array of style names to consume.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names to consume.
* @param {String|Array.<String>} consumables.classes Class name or array of class names to consume.
* @param {String|Array.<String>} consumables.styles Style name or array of style names to consume.
*/
consume( consumables ) {
if ( consumables.name ) {
Expand All @@ -463,9 +457,9 @@ class ViewElementConsumables {
*
* @param {Object} consumables Object describing which parts of the element should be reverted.
* @param {Boolean} consumables.name If set to `true` element's name will be reverted.
* @param {String|Array.<String>} consumables.attribute Attribute name or array of attribute names to revert.
* @param {String|Array.<String>} consumables.class Class name or array of class names to revert.
* @param {String|Array.<String>} consumables.style Style name or array of style names to revert.
* @param {String|Array.<String>} consumables.attributes Attribute name or array of attribute names to revert.
* @param {String|Array.<String>} consumables.classes Class name or array of class names to revert.
* @param {String|Array.<String>} consumables.styles Style name or array of style names to revert.
*/
revert( consumables ) {
if ( consumables.name ) {
Expand All @@ -486,7 +480,7 @@ class ViewElementConsumables {
* type is provided - it should be handled separately by providing actual style/class type.
*
* @private
* @param {String} type Type of the consumable item: `attribute`, `class` or `style`.
* @param {String} type Type of the consumable item: `attributes`, `classes` or `styles`.
* @param {String|Array.<String>} item Consumable item or array of items.
*/
_add( type, item ) {
Expand Down Expand Up @@ -520,7 +514,7 @@ class ViewElementConsumables {
* Helper method that tests consumables of a given type: attribute, class or style.
*
* @private
* @param {String} type Type of the consumable item: `attribute`, `class` or `style`.
* @param {String} type Type of the consumable item: `attributes`, `classes` or `styles`.
* @param {String|Array.<String>} item Consumable item or array of items.
* @returns {Boolean|null} Returns `true` if all items can be consumed, `null` when one of the items cannot be
* consumed and `false` when one of the items is already consumed.
Expand All @@ -531,8 +525,10 @@ class ViewElementConsumables {

for ( const name of items ) {
if ( type === 'attributes' && ( name === 'class' || name === 'style' ) ) {
const consumableName = name == 'class' ? 'classes' : 'styles';

// Check all classes/styles if class/style attribute is tested.
const value = this._test( name, [ ...this._consumables[ name ].keys() ] );
const value = this._test( consumableName, [ ...this._consumables[ consumableName ].keys() ] );

if ( value !== true ) {
return value;
Expand All @@ -557,7 +553,7 @@ class ViewElementConsumables {
* Helper method that consumes items of a given type: attribute, class or style.
*
* @private
* @param {String} type Type of the consumable item: `attribute`, `class` or `style`.
* @param {String} type Type of the consumable item: `attributes`, `classes` or `styles`.
* @param {String|Array.<String>} item Consumable item or array of items.
*/
_consume( type, item ) {
Expand All @@ -566,8 +562,10 @@ class ViewElementConsumables {

for ( const name of items ) {
if ( type === 'attributes' && ( name === 'class' || name === 'style' ) ) {
const consumableName = name == 'class' ? 'classes' : 'styles';

// If class or style is provided for consumption - consume them all.
this._consume( name, [ ...this._consumables[ name ].keys() ] );
this._consume( consumableName, [ ...this._consumables[ consumableName ].keys() ] );
} else {
consumables.set( name, false );
}
Expand All @@ -578,7 +576,7 @@ class ViewElementConsumables {
* Helper method that reverts items of a given type: attribute, class or style.
*
* @private
* @param {String} type Type of the consumable item: `attribute`, `class` or , `style`.
* @param {String} type Type of the consumable item: `attributes`, `classes` or , `styles`.
* @param {String|Array.<String>} item Consumable item or array of items.
*/
_revert( type, item ) {
Expand All @@ -587,8 +585,10 @@ class ViewElementConsumables {

for ( const name of items ) {
if ( type === 'attributes' && ( name === 'class' || name === 'style' ) ) {
const consumableName = name == 'class' ? 'classes' : 'styles';

// If class or style is provided for reverting - revert them all.
this._revert( name, [ ...this._consumables[ name ].keys() ] );
this._revert( consumableName, [ ...this._consumables[ consumableName ].keys() ] );
} else {
const value = consumables.get( name );

Expand Down

0 comments on commit f61cc3e

Please sign in to comment.