Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map polyfill fails (in certain use cases?) on IE11 using default-3.4 or newer #118

Closed
DonGissel opened this issue Dec 15, 2017 · 16 comments
Closed
Assignees

Comments

@DonGissel
Copy link

Using IE11 (11.1884.14393.0) and polyfill service 3.24, the polyfill string default-3.6,Map will fail (telling me Object doesn't support property or method 'entries', polyfill.js 434:3). However, default-3.3,Map works just fine; as does default-3.6 without added bonuses, but this seems fully dependent on the use case. Adding Map to any default-version from 3.4 and above will fail. The failing block in question looks like this:

	Map.prototype['forEach'] = function(callbackFn, thisArg) {
		thisArg = thisArg || global;
		var iterator = this.entries(); // <- Right here!
		var result = iterator.next();
		while (result.done === false) {
			callbackFn.call(thisArg, result.value[1], result.value[0], this);
			result = iterator.next();
		}
	};

Polyfill header:

/* Polyfill service v3.24.0
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 * 
 * UA detected: ie/11.0.0
 * Features requested: Map,default-3.6

Now, I know that Map is already included in default-3.6, but in certain cases that fails as well, without clear indication of what's gone wrong. default-3.6,fetch fails for one of our sites inside the Map-polyfill on IE11 with the message Unable to get property 'get' of undefined or null reference (polyfill.js 1303,3), here:

	var isMap;
	if (hasMap) {
		var mapSize = Object.getOwnPropertyDescriptor(Map.prototype, 'size').get; // Here!
		isMap = function (m) {
			try {
				mapSize.call(m);
				return true;
			} catch (e) {
				return false;
			}
		};
	}

Polyfill header for that one:

/* Polyfill service v3.24.0
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 * 
 * UA detected: ie/11.0.0
 * Features requested: default-3.6,fetch

That's about all the detail I can give you presently. Any idea of how to fix this?

@DonGissel
Copy link
Author

It seems the offending code from the first example comes from here:

https://github.com/Financial-Times/polyfill-service/blame/master/polyfills/Map/polyfill.js#L244

And the second from here (not at all what I expected):

https://github.com/Financial-Times/polyfill-service/blame/master/polyfills/Array/from/polyfill.js#L172

@JakeChampion
Copy link
Owner

@DonGissel Can you post a small reproducible example on jsbin.com for this please?

@DonGissel
Copy link
Author

Issue 1, for starters:
http://output.jsbin.com/noresanisi/4/

... still trying to reproduce issue 2.

@lechneal
Copy link

lechneal commented Dec 18, 2017

I get issue 2 when using polyfill with googlemaps in IE11.
Sample here:
http://jsbin.com/kicebekoqe/

I get this in IE11:
Unable to get property 'get' of undefined or null reference
at this line:

var mapSize = Object.getOwnPropertyDescriptor(Map.prototype, 'size').get;

@luruke
Copy link

luruke commented Dec 20, 2017

Same problem here @lechneal ,
error with IE11 + google maps.

@steshaw
Copy link

steshaw commented Dec 27, 2017

We are seeing the same exception on IE10 Windows 7 using polyfill v2. i.e. The Object.getOwnPropertyDescriptor(Map.prototype, 'size').get fails with Unable to get property 'get' of undefined or null reference.

If you type the above expression into the console, you can provoke the error.

@bjornefar
Copy link

Are there any news on this issue? I am still getting the same error with the setup @luruke uses.

@sanderwapstra
Copy link

sanderwapstra commented Jan 25, 2018

Same problem here with Google Maps and IE11, when adding Array.from to the features list.

@JakeChampion JakeChampion self-assigned this Jan 25, 2018
@maxcbc
Copy link

maxcbc commented Jul 30, 2018

I'm getting this (issue 2) too. IE11 on Windows 7.

Object.getOwnPropertyDescriptor(Map.prototype, 'size').get fails with Unable to get property 'get' of undefined or null reference.

@maxcbc
Copy link

maxcbc commented Jul 30, 2018

Update: I'm getting this on the standard default.

Also this seems to be happening because Object.getOwnPropertyDescriptor(Map.prototype, 'size').get before Map is polyfilled, thus Map.prototype.size has not yet been added.

@jonathantneal
Copy link

When using https://cdn.polyfill.io/v2/polyfill.js?features=default-3.6 I get the following error in Internet Explorer 11 for Windows 10:

Object doesn't support property or method 'entries'

This happens when something else in the stack attempts to run forEach on a new Set.

@kachkaev
Copy link

kachkaev commented Oct 18, 2018

I was also seeing cannot get property "get" of undefined or null reference in IE11 when opening my Next.js app that uses Apollo Client (the exception was thrown only on those pages that invoke client-side GraphQL queries).

Manually adding Map to the list of polyfills helped! 🎉

  <script
-   src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,Intl.~locale.ru,Intl.~locale.en"
+   src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Map,fetch,Intl.~locale.ru,Intl.~locale.en"
    async={false}
  />

This fills a bit odd because Map is marked as included by default in the list of features. Anyway, I'm glad to see my problem resolved and I'd like to thank the authors of polyfill.io for such an awesome library given the opportunity!

@JakeChampion
Copy link
Owner

@kachkaev Thank you for the kind words! You are correct, Map is in the default set however, the script src you posted is using a custom set of features and has not included the default set. If you want a custom set alongside the default set, you can achieve that like so:

  <script
-   src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Map,fetch,Intl.~locale.ru,Intl.~locale.en"
+   src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,fetch,Intl.~locale.ru,Intl.~locale.en"
    async={false}
  />

@Anima-t3d
Copy link

Still happening on IE11. Using: https://cdn.polyfill.io/v2/polyfill.min.js?features=default,EventSource,Math.cbrt,Array.prototype.findIndex

@richseviora
Copy link

I am also having the same error in IE11 where https://cdn.polyfill.io/v2/polyfill.min.js?features=default-3.6 would generate the error.

@JakeChampion JakeChampion transferred this issue from polyfillpolyfill/polyfill-service Feb 6, 2019
@JakeChampion
Copy link
Owner

This looks to be fixed in v3 of polyfill.io. I tested all the jsbin links in this thread and none of them are throwing errors :-)

bs_win10_ie_11 0 3

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests