PropertyNode.js 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { InputNode } from '../core/InputNode.js';
  2. function PropertyNode( object, property, type ) {
  3. InputNode.call( this, type );
  4. this.object = object;
  5. this.property = property;
  6. }
  7. PropertyNode.prototype = Object.create( InputNode.prototype );
  8. PropertyNode.prototype.constructor = PropertyNode;
  9. PropertyNode.prototype.nodeType = 'Property';
  10. Object.defineProperties( PropertyNode.prototype, {
  11. value: {
  12. get: function () {
  13. return this.object[ this.property ];
  14. },
  15. set: function ( val ) {
  16. this.object[ this.property ] = val;
  17. }
  18. }
  19. } );
  20. PropertyNode.prototype.toJSON = function ( meta ) {
  21. var data = this.getJSONNode( meta );
  22. if ( ! data ) {
  23. data = this.createJSONNode( meta );
  24. data.value = this.value;
  25. data.property = this.property;
  26. }
  27. return data;
  28. };
  29. export { PropertyNode };