Closed filodej closed 7 years ago
Defining unknownElement or unknownAttribute as a function is much more powerful than a static definition.
unknownElement
unknownAttribute
Instead of the following distributed logic:
var docSpec={ unknownElement: { menu: [{ caption: function(jsElement) { 'Delete <'+jsElement.name+'>'; }, action: Xonomy.deleteElement, hideIf: function(jsElement) { return jsElement.name === 'root'; } }]; }, unknownAttribute: {...} };
... we can make the condition logic centralized as follows:
var docSpec={ unknownElement: function(elName){ return (elName !== 'root') ? { menu: [{ caption: 'Delete <'+elName+'>', action: Xonomy.deleteElement }]} : {}; }, unknownAttribute: function(elName, attrName) { ... }, };
... and for more advanced use-cases it may not be even possible to statically define specification up-front.
Very clever. Now people will want to put everything in these functions and .elements will be empty! :-)
.elements
Defining
unknownElement
orunknownAttribute
as a function is much more powerful than a static definition.Instead of the following distributed logic:
... we can make the condition logic centralized as follows:
... and for more advanced use-cases it may not be even possible to statically define specification up-front.