AttributeNode.js 839 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import Node from './Node.js';
  2. class AttributeNode extends Node {
  3. constructor( type, name = null, property = null ) {
  4. super( type );
  5. this.name = name;
  6. this.property = property;
  7. }
  8. setAttributeName( name ) {
  9. this.name = name;
  10. return this;
  11. }
  12. getAttributeName( /*builder*/ ) {
  13. return this.name;
  14. }
  15. setAttributeProperty( name ) {
  16. this.property = name;
  17. return this;
  18. }
  19. getAttributeProperty( builder ) {
  20. const attribute = builder.getAttribute( this.getType( builder ), this.getAttributeName( builder ), this.property );
  21. return attribute.property;
  22. }
  23. generate( builder, output ) {
  24. const attributeProperty = this.getAttributeProperty( builder );
  25. return builder.format( attributeProperty, this.getType( builder ), output );
  26. }
  27. }
  28. export default AttributeNode;