RootAttributeOperation
Operation to change root element's attribute. Using this class you can add, remove or change value of the attribute.
This operation is needed, because root elements can't be changed through AttributeOperation. It is because AttributeOperation requires a range to change and root element can't be a part of range because every ModelPosition has to be inside a root. ModelPosition can't be created before a root element.
Properties
affectedSelectable : ModelSelectablereadonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#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/rootattributeoperation~RootAttributeOperation#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/rootattributeoperation~RootAttributeOperation#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/rootattributeoperation~RootAttributeOperation#isDocumentOperationDefines whether operation is executed on attached or detached items.
key : stringreadonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#keyKey of an attribute to change or remove.
newValue : unknownreadonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#newValueNew value of the attribute with given key or
null, if operation should remove attribute.oldValue : unknownreadonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#oldValueOld value of the attribute with given key or
null, if attribute was not set before.root : ModelRootElementreadonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#rootRoot element to change.
type : 'addRootAttribute' | 'removeRootAttribute' | 'changeRootAttribute'readonlymodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#typeOperation type.
Static properties
className : stringreadonlystaticmodule:engine/model/operation/rootattributeoperation~RootAttributeOperation.classNameName of the operation class used for serialization.
Methods
constructor( root, key, oldValue, newValue, baseVersion )module:engine/model/operation/rootattributeoperation~RootAttributeOperation#constructorCreates an operation that changes, removes or adds attributes on root element.
Parameters
root : ModelRootElementRoot element to change.
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.
Related:
module:engine/model/operation/rootattributeoperation~RootAttributeOperation#cloneCreates and returns an operation that has the same parameters as this operation.
Returns
RootAttributeOperationClone of this operation.
getReversed() → Operationmodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#getReversedtoJSON() → unknownmodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#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/rootattributeoperation~RootAttributeOperation#_executeExecutes the operation - modifications described by the operation properties will be applied to the model tree.
Returns
void
_validate() → voidinternalmodule:engine/model/operation/rootattributeoperation~RootAttributeOperation#_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 ) → RootAttributeOperationstaticmodule:engine/model/operation/rootattributeoperation~RootAttributeOperation.fromJSONCreates
RootAttributeOperationobject from deserialized object, i.e. from parsed JSON string.Parameters
json : anyDeserialized JSON object.
document : ModelDocumentDocument on which this operation will be applied.
Returns