aboutsummaryrefslogtreecommitdiffstats
path: root/vanilla/node_modules/@acemir/cssom/lib/CSSOM.js
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 21:34:48 -0800
commit76cb9c2a39d477a64824a985ade40507e3bbade1 (patch)
tree41e997aa9c6f538d3a136af61dae9424db2005a9 /vanilla/node_modules/@acemir/cssom/lib/CSSOM.js
parent819a39a21ac992b1393244a4c283bbb125208c69 (diff)
downloadneko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.gz
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.tar.bz2
neko-76cb9c2a39d477a64824a985ade40507e3bbade1.zip
feat(vanilla): add testing infrastructure and tests (NK-wjnczv)
Diffstat (limited to 'vanilla/node_modules/@acemir/cssom/lib/CSSOM.js')
-rw-r--r--vanilla/node_modules/@acemir/cssom/lib/CSSOM.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/vanilla/node_modules/@acemir/cssom/lib/CSSOM.js b/vanilla/node_modules/@acemir/cssom/lib/CSSOM.js
new file mode 100644
index 0000000..08d47cb
--- /dev/null
+++ b/vanilla/node_modules/@acemir/cssom/lib/CSSOM.js
@@ -0,0 +1,58 @@
+var CSSOM = {
+ /**
+ * Creates and configures a new CSSOM instance with the specified options.
+ *
+ * @param {Object} opts - Configuration options for the CSSOM instance
+ * @param {Object} [opts.globalObject] - Optional global object to be assigned to CSSOM objects prototype
+ * @returns {Object} A new CSSOM instance with the applied configuration
+ * @description
+ * This method creates a new instance of CSSOM and optionally
+ * configures CSSStyleSheet with a global object reference. When a globalObject is provided
+ * and CSSStyleSheet exists on the instance, it creates a new CSSStyleSheet constructor
+ * using a factory function and assigns the globalObject to its prototype's __globalObject property.
+ */
+ setup: function (opts) {
+ var instance = Object.create(this);
+ if (opts.globalObject) {
+ if (instance.CSSStyleSheet) {
+ var factoryCSSStyleSheet = createFunctionFactory(instance.CSSStyleSheet);
+ var CSSStyleSheet = factoryCSSStyleSheet();
+ CSSStyleSheet.prototype.__globalObject = opts.globalObject;
+
+ instance.CSSStyleSheet = CSSStyleSheet;
+ }
+ }
+ return instance;
+ }
+};
+
+function createFunctionFactory(fn) {
+ return function() {
+ // Create a new function that delegates to the original
+ var newFn = function() {
+ return fn.apply(this, arguments);
+ };
+
+ // Copy prototype chain
+ Object.setPrototypeOf(newFn, Object.getPrototypeOf(fn));
+
+ // Copy own properties
+ for (var key in fn) {
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
+ newFn[key] = fn[key];
+ }
+ }
+
+ // Clone the .prototype object for constructor-like behavior
+ if (fn.prototype) {
+ newFn.prototype = Object.create(fn.prototype);
+ }
+
+ return newFn;
+ };
+}
+
+//.CommonJS
+module.exports = CSSOM;
+///CommonJS
+