AttributeOperation
Operation to change nodes' attribute.
Using this class you can add, remove or change value of the attribute.
Properties
affectedSelectable : ModelSelectablereadonlymodule:engine/model/operation/attributeoperation~AttributeOperation#affectedSelectableA selectable that will be affected by the operation after it is executed.
The exact returned parameter differs between operation types.
baseVersion : null | numberinheritedmodule:engine/model/operation/attributeoperation~AttributeOperation#baseVersionversionon which operation can be applied. If you try to apply operation with different base version than the document version the model-document-applyOperation-wrong-version error is thrown.module:engine/model/operation/attributeoperation~AttributeOperation#batchBatch to which the operation is added or
nullif the operation is not added to any batch yet.Note, that a non-document operation has this property always set to
null, and is never added to any batch.isDocumentOperation : booleanreadonlyinheritedmodule:engine/model/operation/attributeoperation~AttributeOperation#isDocumentOperationDefines whether operation is executed on attached or detached items.
key : stringreadonlymodule:engine/model/operation/attributeoperation~AttributeOperation#keyKey of an attribute to change or remove.
newValue : unknownreadonlymodule:engine/model/operation/attributeoperation~AttributeOperation#newValueNew value of the attribute with given key or
null, if operation should remove attribute.oldValue : unknownreadonlymodule:engine/model/operation/attributeoperation~AttributeOperation#oldValueOld value of the attribute with given key or
null, if attribute was not set before.range : ModelRangereadonlymodule:engine/model/operation/attributeoperation~AttributeOperation#rangeRange on which operation should be applied.
type : 'removeAttribute' | 'addAttribute' | 'changeAttribute'readonlymodule:engine/model/operation/attributeoperation~AttributeOperation#typeOperation type.
Static properties
className : stringreadonlystaticmodule:engine/model/operation/attributeoperation~AttributeOperation.classNameName of the operation class used for serialization.
Methods
constructor( range, key, oldValue, newValue, baseVersion )module:engine/model/operation/attributeoperation~AttributeOperation#constructorCreates an operation that changes, removes or adds attributes.
If only
newValueis set, attribute will be added on a node. Note that all nodes in operation's range must not have an attribute with the same key as the added attribute.If only
oldValueis set, then attribute with given key will be removed. Note that all nodes in operation's range must have an attribute with that key added.If both
newValueandoldValueare set, then the operation will change the attribute value. Note that all nodes in operation's ranges must already have an attribute with given key andoldValueas valueParameters
range : ModelRangeRange on which the operation should be applied. Must be a flat range.
key : stringKey of an attribute to change or remove.
oldValue : unknownOld value of the attribute with given key or
null, if attribute was not set before.newValue : unknownNew value of the attribute with given key or
null, if operation should remove attribute.baseVersion : null | numberDocument
versionon which operation can be applied ornullif the operation operates on detached (non-document) tree.
module:engine/model/operation/attributeoperation~AttributeOperation#cloneCreates and returns an operation that has the same parameters as this operation.
Returns
getReversed() → Operationmodule:engine/model/operation/attributeoperation~AttributeOperation#getReversedtoJSON() → unknownmodule:engine/model/operation/attributeoperation~AttributeOperation#toJSONCustom toJSON method to solve child-parent circular dependencies.
Returns
unknownClone of this object with the operation property replaced with string.
_execute() → voidinternalmodule:engine/model/operation/attributeoperation~AttributeOperation#_executeExecutes the operation - modifications described by the operation properties will be applied to the model tree.
Returns
void
_validate() → voidinternalmodule:engine/model/operation/attributeoperation~AttributeOperation#_validateChecks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.
Returns
void
Static methods
fromJSON( json, document ) → AttributeOperationstaticmodule:engine/model/operation/attributeoperation~AttributeOperation.fromJSONCreates
AttributeOperationobject from deserialized object, i.e. from parsed JSON string.Parameters
json : anyDeserialized JSON object.
document : ModelDocumentDocument on which this operation will be applied.
Returns