Repository URL to install this package:
Version:
1.2.9 ▾
|
"use strict";
// @flow
/* These are helpers for the StyleTags to keep track of the injected
* rule names for each (component) ID that they're keeping track of.
* They're crucial for detecting whether a name has already been
* injected.
* (This excludes rehydrated names) */
Object.defineProperty(exports, "__esModule", { value: true });
/* adds a new ID:name pairing to a names dictionary */
exports.addNameForId = (names, id, name) => {
if (name) {
// eslint-disable-next-line no-param-reassign
const namesForId = names[id] || (names[id] = Object.create(null));
namesForId[name] = true;
}
};
/* resets an ID entirely by overwriting it in the dictionary */
exports.resetIdNames = (names, id) => {
// eslint-disable-next-line no-param-reassign
names[id] = Object.create(null);
};
/* factory for a names dictionary checking the existance of an ID:name pairing */
exports.hasNameForId = (names) => (id, name) => names[id] !== undefined && names[id][name];
/* stringifies names for the html/element output */
exports.stringifyNames = (names) => {
let str = '';
// eslint-disable-next-line guard-for-in
for (const id in names) {
str += `${Object.keys(names[id]).join(' ')} `;
}
return str.trim();
};
/* clones the nested names dictionary */
exports.cloneNames = (names) => {
const clone = Object.create(null);
// eslint-disable-next-line guard-for-in
for (const id in names) {
clone[id] = Object.assign({}, names[id]);
}
return clone;
};
//# sourceMappingURL=styleNames.js.map