@atlassian/aui
Version:
Atlassian User Interface Framework
52 lines (47 loc) • 1.6 kB
JavaScript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['module', 'exports'], factory);
} else if (typeof exports !== "undefined") {
factory(module, exports);
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports);
global.state = mod.exports;
}
})(this, function (module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function state(element) {
return {
/**
* sets an internal state on a component element
* @param element the element to which the state will be added
* @param stateName the name of the state
* @param stateValue the value that the state will be changed to
*/
set: function set(stateName, stateValue) {
if (element._state === undefined) {
element._state = {};
}
element._state[stateName] = stateValue;
},
/**
* gets an internal state on a component element
* @param element the element to which the state will be added
* @param stateName the name of the state
*/
get: function get(stateName) {
if (element._state) {
return element._state[stateName];
}
}
};
}
exports.default = state;
module.exports = exports['default'];
});
//# sourceMappingURL=state.js.map