Skip to content

Commit

Permalink
fix resize observer (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke authored Jul 1, 2024
1 parent 78bc62a commit cdd9584
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
36 changes: 36 additions & 0 deletions polyfills/ResizeObserver/patch.jsdiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
===================================================================
--- a/polyfills/ResizeObserver/polyfill.js
+++ b/polyfills/ResizeObserver/polyfill.js
@@ -1,8 +1,4 @@
-(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ResizeObserver = {}));
-})(this, (function (exports) { 'use strict';
+(function (global) {

var resizeObservers = [];

@@ -109,7 +105,7 @@

var cache = new WeakMap();
var scrollRegexp = /auto|scroll/;
- var verticalRegexp = /^tb|vertical/;
+ var verticalRegexp = /^tb|^vertical/;
var IE = (/msie|trident/i).test(global.navigator && global.navigator.userAgent);
var parseDimension = function (pixel) { return parseFloat(pixel || '0'); };
var size = function (inlineSize, blockSize, switchSizes) {
@@ -503,10 +499,7 @@
return ResizeObserver;
}());

- exports.ResizeObserver = ResizeObserver;
- exports.ResizeObserverEntry = ResizeObserverEntry;
- exports.ResizeObserverSize = ResizeObserverSize;
+ global.ResizeObserver = ResizeObserver;
+ global.ResizeObserverEntry = ResizeObserverEntry;

- Object.defineProperty(exports, '__esModule', { value: true });
-
-}));
+}(self));
18 changes: 5 additions & 13 deletions polyfills/ResizeObserver/polyfill.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ResizeObserver = {}));
})(this, (function (exports) { 'use strict';
(function (global) {

var resizeObservers = [];

Expand Down Expand Up @@ -109,7 +105,7 @@

var cache = new WeakMap();
var scrollRegexp = /auto|scroll/;
var verticalRegexp = /^tb|vertical/;
var verticalRegexp = /^tb|^vertical/;
var IE = (/msie|trident/i).test(global.navigator && global.navigator.userAgent);
var parseDimension = function (pixel) { return parseFloat(pixel || '0'); };
var size = function (inlineSize, blockSize, switchSizes) {
Expand Down Expand Up @@ -503,11 +499,7 @@
return ResizeObserver;
}());

exports.ResizeObserver = ResizeObserver;
exports.ResizeObserverEntry = ResizeObserverEntry;
exports.ResizeObserverSize = ResizeObserverSize;
global.ResizeObserver = ResizeObserver;
global.ResizeObserverEntry = ResizeObserverEntry;

Object.defineProperty(exports, '__esModule', { value: true });

}));
;self.ResizeObserverEntry = ResizeObserver.ResizeObserverEntry;self.ResizeObserver=ResizeObserver.ResizeObserver;
}(self));
13 changes: 9 additions & 4 deletions polyfills/ResizeObserver/update.task.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
'use strict';

var fs = require('fs');
var diff = require('diff');
var process = require('process');
var path = require('path');
var resizeObserverPolyfillOutput = path.resolve('polyfills/ResizeObserver/polyfill.js');

var polyfill = fs.readFileSync(resizeObserverPolyfillOutput, 'utf-8');
polyfill += ';self.ResizeObserverEntry = ResizeObserver.ResizeObserverEntry;self.ResizeObserver=ResizeObserver.ResizeObserver;'
fs.writeFileSync(resizeObserverPolyfillOutput, polyfill, 'utf-8');
var polyfill = fs.readFileSync(path.join(__dirname, './polyfill.js'), 'utf8');
var patch = fs.readFileSync(path.join(__dirname, './patch.jsdiff'), 'utf8');

var patched = diff.applyPatch(polyfill, patch);

if (patched === false) {process.exit(1);}
fs.writeFileSync(path.join(__dirname, './polyfill.js'), patched);

0 comments on commit cdd9584

Please sign in to comment.