@atlaskit/tokens
Advanced tools
Comparing version 1.53.1 to 1.53.2
@@ -11,3 +11,2 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags"); | ||
var _constants = require("./constants"); | ||
@@ -33,5 +32,3 @@ var _getGlobalTheme = _interopRequireDefault(require("./get-global-theme")); | ||
this.callback = callback; | ||
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
@@ -41,23 +38,11 @@ (0, _createClass2.default)(ThemeMutationObserver, [{ | ||
value: function observe() { | ||
var _this = this; | ||
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(function () { | ||
var theme = (0, _getGlobalTheme.default)(); | ||
ThemeMutationObserver.callbacks.forEach(function (callback) { | ||
return callback(theme); | ||
}); | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(function () { | ||
var theme = (0, _getGlobalTheme.default)(); | ||
ThemeMutationObserver.callbacks.forEach(function (callback) { | ||
return callback(theme); | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [_constants.THEME_DATA_ATTRIBUTE, _constants.COLOR_MODE_ATTRIBUTE] | ||
}); | ||
} | ||
} else { | ||
if (!this.legacyObserver) { | ||
this.legacyObserver = new MutationObserver(function () { | ||
_this.callback((0, _getGlobalTheme.default)()); | ||
}); | ||
} | ||
this.legacyObserver.observe(document.documentElement, { | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [_constants.THEME_DATA_ATTRIBUTE, _constants.COLOR_MODE_ATTRIBUTE] | ||
@@ -70,13 +55,9 @@ }); | ||
value: function disconnect() { | ||
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} else { | ||
this.legacyObserver && this.legacyObserver.disconnect(); | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} | ||
@@ -83,0 +64,0 @@ }]); |
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { getBooleanFF } from '@atlaskit/platform-feature-flags'; | ||
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants'; | ||
@@ -22,25 +21,12 @@ import getGlobalTheme from './get-global-theme'; | ||
this.callback = callback; | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
observe() { | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(() => { | ||
const theme = getGlobalTheme(); | ||
ThemeMutationObserver.callbacks.forEach(callback => callback(theme)); | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [THEME_DATA_ATTRIBUTE, COLOR_MODE_ATTRIBUTE] | ||
}); | ||
} | ||
} else { | ||
if (!this.legacyObserver) { | ||
this.legacyObserver = new MutationObserver(() => { | ||
this.callback(getGlobalTheme()); | ||
}); | ||
} | ||
this.legacyObserver.observe(document.documentElement, { | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(() => { | ||
const theme = getGlobalTheme(); | ||
ThemeMutationObserver.callbacks.forEach(callback => callback(theme)); | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [THEME_DATA_ATTRIBUTE, COLOR_MODE_ATTRIBUTE] | ||
@@ -51,13 +37,9 @@ }); | ||
disconnect() { | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} else { | ||
this.legacyObserver && this.legacyObserver.disconnect(); | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} | ||
@@ -64,0 +46,0 @@ } |
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { getBooleanFF } from '@atlaskit/platform-feature-flags'; | ||
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants'; | ||
@@ -25,5 +24,3 @@ import getGlobalTheme from './get-global-theme'; | ||
this.callback = callback; | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
ThemeMutationObserver.callbacks.add(callback); | ||
} | ||
@@ -33,23 +30,11 @@ _createClass(ThemeMutationObserver, [{ | ||
value: function observe() { | ||
var _this = this; | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(function () { | ||
var theme = getGlobalTheme(); | ||
ThemeMutationObserver.callbacks.forEach(function (callback) { | ||
return callback(theme); | ||
}); | ||
if (!ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer = new MutationObserver(function () { | ||
var theme = getGlobalTheme(); | ||
ThemeMutationObserver.callbacks.forEach(function (callback) { | ||
return callback(theme); | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [THEME_DATA_ATTRIBUTE, COLOR_MODE_ATTRIBUTE] | ||
}); | ||
} | ||
} else { | ||
if (!this.legacyObserver) { | ||
this.legacyObserver = new MutationObserver(function () { | ||
_this.callback(getGlobalTheme()); | ||
}); | ||
} | ||
this.legacyObserver.observe(document.documentElement, { | ||
}); | ||
// Observer only needs to be configured once | ||
ThemeMutationObserver.observer.observe(document.documentElement, { | ||
attributeFilter: [THEME_DATA_ATTRIBUTE, COLOR_MODE_ATTRIBUTE] | ||
@@ -62,13 +47,9 @@ }); | ||
value: function disconnect() { | ||
if (getBooleanFF('platform.design-system-team.mutation-observer-performance-improvement_8usdg')) { | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} else { | ||
this.legacyObserver && this.legacyObserver.disconnect(); | ||
if (this.callback) { | ||
ThemeMutationObserver.callbacks.delete(this.callback); | ||
} | ||
if (ThemeMutationObserver.callbacks.size === 0 && ThemeMutationObserver.observer) { | ||
ThemeMutationObserver.observer.disconnect(); | ||
ThemeMutationObserver.observer = null; | ||
} | ||
} | ||
@@ -75,0 +56,0 @@ }]); |
{ | ||
"name": "@atlaskit/tokens", | ||
"version": "1.53.1", | ||
"version": "1.53.2", | ||
"description": "Design tokens are the single source of truth to name and store design decisions.", | ||
@@ -133,5 +133,2 @@ "publishConfig": { | ||
"type": "boolean" | ||
}, | ||
"platform.design-system-team.mutation-observer-performance-improvement_8usdg": { | ||
"type": "boolean" | ||
} | ||
@@ -138,0 +135,0 @@ }, |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10638711
240454