PropertyNode.js 874 B

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