base.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
  4. var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
  5. var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
  6. var _emit = _interopRequireDefault(require("./graphic/event/emit"));
  7. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  8. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  9. var Util = require('./util/common');
  10. var Base = /*#__PURE__*/function (_Emit) {
  11. (0, _inheritsLoose2["default"])(Base, _Emit);
  12. var _super = _createSuper(Base);
  13. var _proto = Base.prototype;
  14. _proto.getDefaultCfg = function getDefaultCfg() {
  15. return {};
  16. };
  17. function Base(cfg) {
  18. var _this;
  19. _this = _Emit.call(this) || this;
  20. var attrs = {};
  21. var defaultCfg = _this.getDefaultCfg();
  22. _this._attrs = attrs;
  23. Util.mix(attrs, defaultCfg, cfg);
  24. return _this;
  25. }
  26. _proto.get = function get(name) {
  27. return this._attrs[name];
  28. };
  29. _proto.set = function set(name, value) {
  30. this._attrs[name] = value;
  31. };
  32. _proto.destroy = function destroy() {
  33. this._attrs = {};
  34. this.destroyed = true;
  35. };
  36. return Base;
  37. }(_emit["default"]);
  38. module.exports = Base;