Giter Club home page Giter Club logo

polyfill-library's People

Contributors

actions-user avatar alenaksu avatar andrewgadziksonos avatar cdaringe avatar chee avatar cheloxl avatar christophehurpeau avatar cyjake avatar dependabot-preview[bot] avatar dependabot[bot] avatar doniyor2109 avatar github-actions[bot] avatar jakechampion avatar juliyvchirkov avatar krinkle avatar longlho avatar magic-akari avatar matzimowski avatar mhassan1 avatar mridgway avatar neenhouse avatar nickcolley avatar nicksrandall avatar notlee avatar plesiecki avatar radeno avatar romainmenke avatar sbinlondon avatar snyk-bot avatar undefinedbehaviour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polyfill-library's Issues

Use live feature detection instead of being based on User-Agent

I would like to have this process:

  1. I define which APIs (from your polyfills directory) I want to have polyfilled.
  2. In my web pages, live feature detection is performed in the browser for those APIs, a custom //cdn.polyfill.io/v1/polyfill.min.js?features= <auto generated> &ua=false&gated=1 URL is generated (tailored to the browser and with ua disabled) and the corresponding bundle is requested and inserted into the page.

Beside having feature detection, another advantage of this approach is that it enables defining a set of APIs which are all already available in modern browsers (e.g. Chrome, Firefox), in which case Step 2 from above generates an empty "features" list, so nothing has to be requested (= we save the HTTP request completely for those browsers).

How this could work:

  1. The feature detection code (Step 2) would be auto-generated from the list (Step 1) and inlined in the website's pages. This could be performed via a (Grunt & co.) task.
  2. This code would then request the polyfill bundle by document.write()-ing a <script> onto the page (needed to perform a sync request).

Do my thoughts make sense? :)

Desirable breaking changes for next major release

This issue is here to collect / document our proposals for changes we'd like to make but will need to wait for the 4.0 release because they break backwards compatibility:

Update the features data model

Current model is rather clunky:

features: {
  "default": { flags: ["gated", "always"] }
}

Proposed:

features: {
   "default": { "includeDetect": true, "force": true }
}

Or maybe create a stateful polyfill bundle instance:

const bundle1 = new PolyfillBundleDefinition();
bundle1.addFeature('default', { includeDetect: true });
bundle1.setUserAgent(...);
const outputStream = bundle1.generateBundle();

Turn 'gated' (now includeDetect) on by default

The fact that we don't include feature detects by default is a hangover from the previous service that we inherited. With increasingly complexity in targeting, it is obvious that not all polyfills are targeted perfectly. We should wrap polyfills in a detect by default, and refactor the features model (as above) to allow the flag to be explicitly turned off (note that this also requires a breaking change to the HTTP API)

Make streams the default return format

To help avoid creating large in-memory objects for big bundles

Make 'polyfill' the default value for the unknown option

This appears to match more closely with user expectations.

Force includeDetect to be on if unknown=polyfill

To avoid triggering issues in browsers that we haven't tested on.

IntersectionObserverEntry is not being included on older Chromes, e.g. 49

I believe the config.json file for this polyfill is incomplete - only includes Edge 15.

Older Chromes, e.g. Chome 49 do not support "isIntersecting", i.e. they fail this check:

'isIntersecting' in window.IntersectionObserverEntry.prototype

If you add always|gated to the polyfill statement it gets included (and works) correctly.

Array.from(Set.values()) causes exception in IE11

Straight forward to reproduce:

  1. Go to https://polyfill.io/v2/docs/ in IE11
  2. Open up the console
  3. Execute the statement Array.from(new Set([1, 1, 2, 2, 3]).values())
  4. Observe the exception Unable to get property '0' of undefined or null reference. This seems to be coming from the makeIterator function used to polyfill Set.prototype.values.

Why would you want to make such a call? If you have an array of values, tossing them into a set is an easy way to dedupe them.

Call stack from unminified polyfill.js (v3.23.0):

next - polyfill.js (3358, 12)
parseIterable - polyfill.js (2317, 5)
parseIterableLike - polyfill.js (2463, 3)
from - polyfill.js (2497, 4)

Seems like this might be related to #1293 ?

Issue on dependencies resolution

I think there is an issue on the dependencies resolution, enlighten in last Chrome, around Iterator.

See this https://polyfill.io/v2/polyfill.js?features=default,es6,es7 in Chrome 61 for example.

/* Polyfill service v3.21.3
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 * 
 * UA detected: chrome/61.0.0
 * Features requested: default,es6,es7
 * 
 * - Array.prototype.values, License: MIT (required by "es6")
 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.@@iterator", "Array.prototype.values", "es6")
 * - String.prototype.contains, License: CC0 (required by "_ArrayIterator", "Array.prototype.@@iterator", "Array.prototype.values", "es6")
 * - _ArrayIterator, License: MIT (required by "Array.prototype.@@iterator", "Array.prototype.values", "es6") */

...

and this goes on with polyfills for Array.prototype.values, _Iterator, _ArrayIterator, String.prototype.contains

If we look at Array.prototype.values it actually should be polyfilled in Chrome 61, the statement is correct. It depends on Array.prototype.@@iterator and Symbol.iterator which depends on _ArrayIterator

Looking back at the polyfill generated, the header tells us that _Iterator and _ArrayIterator are included because of Array.prototype.values which is a falsy statement.

The entire chain is Array.prototype.values --> Array.prototype.@@iterator --> _ArrayIterator --> _Iterator and this chain should be broke at Array.prototype.@@iterator with Chrome 61 because it supports it.

This make polyfill-service include more useless stuff, and some cannot be gated.

Should we merge the flags always?

the polyfill-liabrary will always merge the flags from feature and alias:

a query like this: default|gated,Promise|always , it is same as default|gated,Promise|always|gated. Actually, i do not want the gated flag, i want to overwrite Promise anyway. There is no way to do things like this. I think we should not merge the flags if there is already flags assigned to feature (like, Promise). A PR has been proposed #1754 , could any one have a look? @JakeChampion

[Feature request] Get polyfills matching multiple user agents

My use case is a bit special, as I don't want to depend on the polyfill-service at runtime (my customers are big corporations, so I often need to deal with corporate firewalls based on a domain whitelist, so adding a new external domain to get polyfills is a costly choice for me).

However, I found this service quite useful when needing to find polyfills for some feature instead of doing the curation myself for each feature.
So what I did is loading https://cdn.polyfill.io/v2/polyfill.js?features=Map,Set&flags=gated&ua=android/4.2.0 and downloading the file in my project. But then, in IE 11, I also needed the Number.isNaN polyfill which is used in the Set polyfill (interestingly, the new version of the Map polyfill does not use it anymore in favor of window.isNaN but it still requires it). and so I had to identify this (comparing the list of included dependencies for ie/11.0.0 and android/4.2.0 to get missing pieces.

For my case, it would be great to be able to specify multiple user agents (android/4.2.0 and ie/11.0.0 in this case) and get the polyfills needed for any of these user agents. My use case would be to create a bundle corresponding to my baseline browsers to serve it.
the always flag does not solve my use case, as it would also include dependencies which are supported by all my baseline browsers.

In ES3 environment, Object.getOwnPropertyNames can return fewer & different results than Object.keys

This issue comes up under JScript/WScript on Windows (UA-detected as equivalent to IE7).

Obviously, I understand that, in an ES3 environment, any non-native object property will be enumerable, and unknown non-enumerable properties can't be detected. Therefore, I would expect the output from the Object.keys and Object.getOwnPropertyNames polyfills to be identical. However, that's not the case when I call them against Array.prototype:

/* Polyfill service v3.25.1
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 * 
 * UA detected: ie/7.0.0
 * Features requested: es5
 */

>>> Object.keys(Array.prototype)
// every,filter,forEach,indexOf,lastIndexOf,map,reduce,reduceRight,some,toString,toLocaleString
>>> Object.getOwnPropertyNames(Array.prototype)
// every,filter,forEach,indexOf,lastIndexOf,map,reduce,reduceRight,some,length

When I do the exact same thing using polyfills from es5-shim & es5-sham instead, both calls return results equivalent to Object.keys above. Does this imply a problem with the polyfill-service implementation of Object.getOwnPropertyNames?

// using es5-shim & es5-sham instead

>>> Object.keys(Array.prototype)
// forEach,map,filter,every,some,reduce,reduceRight,indexOf,lastIndexOf,toString,toLocaleString
>>> Object.getOwnPropertyNames(Array.prototype)
// forEach,map,filter,every,some,reduce,reduceRight,indexOf,lastIndexOf,toString,toLocaleString

Object.entries & Object.values not tagged for IE7, IE8

When requesting es2017 features in a JScript environment (which is detected as IE7, shown below), I didn't get Object.entries or Object.values as I expected.

It looks like these polyfills are tagged only for IE9 and up. Why are IE7 and IE8 excluded?

https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Object/entries/config.json (shows "ie": "9 - 14")

/* Polyfill service v3.25.1
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 *
 * UA detected: ie/7.0.0
 * Features requested: JSON,es2016,es2017,es2018,es5,es6
 *

polyfill(.min).js fails in JScript environment (not finding the global object)

For some of what I do, I'm stuck working in a JScript environment, which means ES3. Thankfully, I found this project recently, and it's really helped to ease the pain - being able to use things like Object.assign, Object.keys, and Array.prototype.forEach in this environment (without having to write them myself) helps quite a lot!

However, before I could get it to work, I had to make a manual edit to the downloaded polyfill(.min).js file. It turns out that the global-object detection logic at the very end fails in the JScript environment. To fix this, I changed the very end of the final .call to reference the this keyword, instead of a new empty object:

// before
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});

// after
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || this);

Not sure if this would be a good solution for other environments, but it definitely fixes the problem for my situation.

If it helps, here's the header of the file I got when I linked to your polyfill service from a .wsf file - WScript appears to be detected as IE7, which seems about right.

/* Polyfill service v3.25.1
 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
 *
 * UA detected: ie/7.0.0
 * Features requested: JSON,es2016,es2017,es2018,es5,es6
 *

Support FormData polyfill

There are many common scenarios for raising issues against the polyfill service. Is your issue one of these?

  • Please add polyfill FormData

Polyfill fails in IE11 when using Array.from of a Map

Normally, applying Array.from to a JavaScript Map results in an array of [key, value] tuples. However, when using polyfill.io with default features in IE11, it results in an array of undefined.

Here is a repro:

var fooMap = new Map()
  .set("key1", "value1")
  .set("key2", "value2");

var fooKeys = Array.from(fooMap.keys());
console.log("first key", fooKeys[0]); // works fine

var fooPairs = Array.from(fooMap);
console.log("first pair", fooPairs[0]); // in IE11, results in an array of undefined instead of key/value tuples

Please see this CodePen for a live demo of the problem.

Remove performance.now from dependencies of requestAnimationFrame.

I think we should remove the performance from requestAnimationFrame's dependencies, because performance.now just adds a broken performance, which does not have measure and many other features. Many applications will check performance and use its once window.performance is not undefined. I think it is better to remove the performance.now from requestAnimationFrame and just use something like inline polyfill.

        var nowOffset = Date.now();

	// use performance api if exist, otherwise use Date.now.
	// Date.now polyfill required.
	var pnow = function () {
		if (global.performance && typeof global.performance.now === 'function') {
			return global.performance.now();
		}
		// fallback
		return Date.now() - nowOffset;
	};

Element.prototype.dataset polyfill enumerability

When grabbing a DOM element using document.getElementById and calling dataset, the returned object is not enumerable. The polyfill is setting the properties enumerable value to the elements enumerable value, but for DOM elements it is undefined. This results in a for-in loop not working. Is there a workaround or can the enumerable value for the properties just be set to true?

This occurs in IE 9 and 10.

setPrototypeOf not supported in IE9 - IE10

The config for Object.setPrototypeOf refers to support for IEs 9-11 (https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Object/setPrototypeOf/config.json), but the source repo refers to IE 11+ (https://github.com/paulmillr/es6-shim/blame/master/README.md#L78) -- and indeed am finding errors using IE10 that boil down to the fill behaving incorrectly and causing incorrect inheritance behaviour in babel-transpiled code. (FYI Babel works around not having the setPrototypeOf method present.)

My workaround (for anyone else hitting the same issue) is to add excludes=Object.setPrototypeOf to my polyfill URL (so I'm not getting a bad fill added), and add import "core-js/fn/object/set-prototype-of"; early in my code (so that I do have a fill for compatible browsers). This works okay so far.

I'm thinking that the fix here is to not fill setPrototypeOf for IE < 11, but I would imagine lots of other fills are relying on it... happy to submit a PR once steered!

IE11 Array.from on List from immutable.js

I have React application with Redux-form.
Looks like immutable.js is used internally by React (or Redux).
Originally I was going to report an issue for immutable.js,
but I realized that issue is reproducible only when polyfill is used (under IE11).
Application works fine under FireFox (without polyfill).

Under IE11 (with polyfill) next line in parseIterableLike() looks to be a problem

var arr = parseIterable(usingIterator(items));

That line is called from Array.from polyfill.
In my case it should convert List from immutable.js to Array, but in fact original List is returned.
As result "items" parameter is assigned to arrayLike as is (without conversion to Array), because in parseIterableLike() at the end "arr" is false.

var arrayLike = Object(parseIterableLike(items));

Because of no conversion in line below I receive 0, since arrayLike.length is undefined (List from immutable.js has only correct size property)

var len = toInteger(arrayLike.length);

Even after manual changing "len" to correct size of list (using debugger), at the end I receive array of "undefined" items, since in next line "[]" operator doesn't work (because arrayLike is not an array)

kValue = arrayLike[k];

Symbol defines properties on Object prototype

The Symbol polyfill defines all Symbols on the object prototype, which causes unexpected results.

// returns true with polyfill.io using features=Symbol.iterator, should be false
console.log(Symbol.iterator in {}); 

Angular checks for the present on the Symbol.iterator property instead of a non-undefined value when running change detection, which breaks when using polyfill.io.

querySelector with :scope

Internet Explorer 11 and lower with querySelector(":scope ...") gives error

Do you have alternatives for it, or its not supported ?

toggleAttribute

Could you add this polyfill please :)

if (!Element.prototype.toggleAttribute) {
  Element.prototype.toggleAttribute = function(name, force) {
    var forcePassed = arguments.length === 2;
    var forceOn = !!force;
    var forceOff = forcePassed && !force;
    
    if (this.getAttribute(name) !== null) {
      if (forceOn) return true;
      
      this.removeAttribute(name);
      return false;
    } else {
      if (forceOff) return false;
      
      this.setAttribute(name, "");
      return true;
    }
  };
}

Spec -- https://dom.spec.whatwg.org/#dom-element-toggleattribute

Bug: minified version of Function.prototype.name feature detect is incorrect

The feature detect for Function.prototype.name is this:
'name' in Function.prototype && (function x() {}).name === 'x'
but when minified it is turned into this:
"name"in Function.prototype&&"x"===function(){}.name
which is incorrect because "x"===function(){}.name will always evaluate to false.

Pollyfills used: polyfill.js?features=default,es6
Pollyfill with issue: Object.defineProperty

stack trace:

defineProperty | @ | polyfill.js?features=default,es6:414
-- | -- | --
defineProp | @ | polyfill.js?features=default,es6:414
(anonymous function) | @ | app.js:1

I have a library somwhere inside one of my 1 million NPM packages that is trying to defined the property items ontop of an empty array (basically Object.defineProperty([], "items", config)) however the issue is ONLY happening on iOS 8, every other browser is fine with it. For this reason I am unable to figure out which of the million packages is doing this as I browserstack for whatever reasons is having a bad day when it comes to sourcemaps.

This is making it so that I have 0 idea what is causing this error so I cannot just remove the package which is doing this and move on. All that being said, is it correct behaviour for the pollyfill service to fix this? I can't even tell if pollyfill.js is pollyfilling my browser :(

I know this is a useless issue submission with very little info but I'm really at my witts end and this is basically just a cry for help. I am just hoping sombody has seen this before and knows a way to fix it. I'm hoping that it's not that I'm stuck and that theres somthing stupid I need to fix.

Sorry.

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

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?

Array.from fails with Set on IE11

On IE11 (on Windows 10, if that's important), when Array.from is passed a set, the Array.from polyfill is failing to detect the set. This appears to be an issue with the order in which polyfills are being loaded:

Placing a breakpoint in the Array.from polyfill's isSet function, you can see that:

  • executing setSize.call(set) throws an exception
  • executing Object.getOwnPropertyDescriptor(Set.prototype, 'size').get.call(set) succeeds
  • Object.getOwnPropertyDescriptor(Set.prototype, 'size').get === setSize is false

In other words, using an uncaptured value for the Set.prototype.size.get function succeeds, but using the previously captured value fails. So it looks like Array.from is capturing IE11's native Set.size.get function, but then later trying to invoke the polyfilled version and throwing an exception as a result.

Here's what the service is loading

UA detected: ie/11.0.0
Features requested: Array.prototype.@@iterator,Array.prototype.find,Array.prototype.includes,IntersectionObserver,Promise,Symbol,WeakMap,default,fetch,matchMedia,navigator.sendBeacon
Earlier resolutions ``` Object.assign, License: CC0 (required by "default", "_Iterator", "_ArrayIterator", "Array.prototype.@@iterator", "Array.from") Symbol, License: MIT (required by "Map", "default", "Set", "Symbol.iterator", "Array.prototype.@@iterator", "Symbol.species", "_Iterator", "_ArrayIterator", "Array.from", "Symbol.toStringTag") Symbol.iterator, License: MIT (required by "Array.prototype.@@iterator", "Map", "default", "Set", "_Iterator", "_ArrayIterator", "Array.from") Symbol.toStringTag, License: MIT (required by "_Iterator", "_ArrayIterator", "Array.prototype.@@iterator", "Array.from", "default") _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.@@iterator", "Array.from", "default") Object.setPrototypeOf, License: MIT (required by "_ArrayIterator", "Array.prototype.@@iterator", "Array.from", "default") String.prototype.includes, License: CC0 (required by "default", "String.prototype.contains", "_ArrayIterator", "Array.prototype.@@iterator", "Array.from") String.prototype.contains, License: CC0 (required by "_ArrayIterator", "Array.prototype.@@iterator", "Array.from", "default") _ArrayIterator, License: MIT (required by "Array.prototype.@@iterator", "Array.from", "default") Array.prototype.@@iterator, License: CC0 Array.prototype.find, License: CC0 Array.prototype.includes, License: CC0 Event, License: CC0 (required by "default", "IntersectionObserver", "CustomEvent", "XMLHttpRequest", "fetch", "navigator.sendBeacon") IntersectionObserver, License: CC0 Promise, License: MIT (required by "default", "fetch") WeakMap, License: https://github.com/webcomponents/webcomponentsjs/blob/master/LICENSE.md fetch, License: MIT navigator.sendBeacon, License: MIT Number.isFinite, License: MIT (required by "Array.from", "default") ```
Number.isNaN, License: MIT (required by "default", "Array.from", "Map", "Set")
Array.from, License: CC0 (required by "default")
Array.of, License: MIT (required by "default")
followed by ``` Array.prototype.fill, License: CC0 (required by "default") CustomEvent, License: CC0 (required by "default") _DOMTokenList, License: CC0 (required by "DOMTokenList", "default") DOMTokenList, License: CC0 (required by "default") _mutation, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith") DocumentFragment.prototype.append, License: CC0 (required by "default") DocumentFragment.prototype.prepend, License: CC0 (required by "default") Element.prototype.after, License: CC0 (required by "default") Element.prototype.append, License: CC0 (required by "default") Element.prototype.before, License: CC0 (required by "default") Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest") Element.prototype.closest, License: CC0 (required by "default") Element.prototype.prepend, License: CC0 (required by "default") Element.prototype.remove, License: CC0 (required by "default") Element.prototype.replaceWith, License: CC0 (required by "default") Symbol.species, License: MIT (required by "Map", "default", "Set") Map, License: CC0 (required by "default") Node.prototype.contains, License: CC0 (required by "default") ```
Set, License: CC0 (required by "default")
String.prototype.endsWith, License: CC0 (required by "default")
String.prototype.startsWith, License: CC0 (required by "default")
URL, License: CC0 (required by "default")

Illegal Constructor in Android 4.x

Creating events via a constructor is an Illegal constructor type error in the Android 4.x stock browser.

new Event("focusout") and others are throwing.

Wrong IE11 implementation of Date.toLocaleString

Hello! Not sure if this is the right place for this, but if I do:

(new Date).toLocaleString('en', { month: '2-digit', day: '2-digit' })

in a Firefox or Chromium (without polyfill) or even in IE10 after polyfilled by polyfill-service, I get:

"10/18"

But in IE11 I am getting:

"10 18"

(in my native locale (pt-BR) the result is even more different (other browsers: "18/10", IE11: "18 de 10"))

I think that IE11 says it implements Intl, and that's why polyfill-service is not sending the polyfill for it. But I thought it woul be better to report... Maybe you would pefer to force the polyfill in this case. (I think I'll force it using the querystring for polyfill-service)

(I tested IE11 using BrowserStack, not sure if a "local" installed IE11 would behave different, but should not...)

EDIT: Using |always didn't work. IE11 is probably using the native bugged implementation anyway. =(

Edge/IE fail to set Content-Type header on XHR whose body is a typed Blob

https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6047383/

  • Could possible target IE7-11
  • dep: WeakMap
  • A possible solution:
typeof Blob !== 'undefined' && 
typeof XMLHttpRequest !== 'undefined' && 
(function(xhr) {
  var send = xhr.send
  var setRequestHeader = xhr.setRequestHeader
  var wm = new WeakMap

  // If content type is manully set, then we 
  // flag this instance so we don't overide it
  xhr.setRequestHeader = function(key) {
    setRequestHeader.apply(this, arguments)
    
    if (key.toLowerCase() === 'content-type')
      wm.set(this, 1)
  }
  
  xhr.send = function(data) {
    if (data instanceof Blob && data.type && !wm.get(this))
      setRequestHeader.apply(this, ['Content-Type', data.type])
    
    return send.apply(this, arguments)
  }
})(XMLHttpRequest.prototype)

`toString` function is override, `toString(undefined)` return `[object Window]`, not as expect

a few months ago, we use the polyfill service to generate a resource for Map&Set: https://cdn.polyfill.io/v2/polyfill.js?features=Map,Set&flags=always,gated. In order to solve the 'Map/Set is not defined' problems on old browsers, like Android 4.4

but, recently, we met a new problem, something not act as expect
in ios 8.1, we found the 'toString' function act different as other new ios versions
when we loaded the polyfill resource above, we found the toString was override
https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Symbol/polyfill.js#L215

image

toString(undefined) return [object Window], not [object undefined], this result caused other problem in our project, so we wish u can solve this problem.

finally, simulate the problem code line
image

HTMLCanvasElement.toBlob is not served in Mobile Safari 10

The problem can be tested against this UA:

  • Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1

I have reproduced the bug with iPhone 6s Plus, IOS 10.3

Invalid descriptor for property '0'

In IE 11, I'm getting the error:

Invalid descriptor for property '0'

Walking up the call stack, it's stemming from some code that is constructing a DOMTokenList with a body element and 'className':

e=new DOMTokenList(body, 'className');

...which eventually hits this code which throws the error:

_(y,n,r)
  • _ is some function named defineProperty
  • y is some object
  • n is 0
  • r is set to undefined

I'm using this polyfill URL (linebreaks added for readability):

https://cdn.polyfill.io/v2/polyfill.min.js
  ?unknown=polyfill
  &features=
    default%2C
    fetch%2C
    Array.prototype.%40%40iterator%2C
    Array.prototype.find%2C
    Array.prototype.findIndex%2C
    Function.name%2C
    Number.isFinite%2C
    Promise%2C
    String.prototype.repeat%2C
    Array.prototype.includes%2C
    Intl.~locale.en-US%2C
    Promise.prototype.finally

How to support Shadow DOM

With Custom Element support in #1376, it'd be great to land Shadow DOM as well. Problem is, because of how hard Shadow DOM is to polyfill, it's broken into two shims:

  • ShadyDOM, shim for DOM aspect of Shadow DOM (attachShadow, shim .children etc)
  • ShadyCSS, shim for scoping styles applied in a Shadow Root. Trickier to use - much less of a polyfill than ShadyDOM, can't just drop in and go.

Given this, what's the best way to attempt loading these polyfills? Could they perhaps be loaded as ShadowDOM.~ShadyDOM and ShadowDOM.~ShadyCSS with ShadowDOM feature importing both? e.g. if you want to use all of Polymer's features, you need to import both. But a library like SkateJS or just vanilla web components, you may only choose ShadyDOM

Thanks, and happy to make a PR if can work this out :)

flat/flatMap

Please add polyfills Array.prototype.flat, Array.prototype.flatMap

These methods are supported in all modern browsers except Edge. A polyfill can be found here:

https://gist.github.com/Kovensky/921c58de0c58be01aebf06d86cf9692f

flat

Flattens an array. You can specify how deep it should be flattened. The depth defaults to 1:

let nested = [
  [ 1, 2, [ 3 ] ],
  [ 3, [ 4 ], 5 ],
  [ [ 5 ], 6, 7 ]
];

nested.flat()  // returns [ 1, 2, [ 3 ], 3, [ 4 ], 5, [ 5 ], 6, 7 ]
nested.flat(2) // returns [ 1, 2, 3, 3, 4, 5, 5, 6, 7 ]

flatMap

Maps an array, then flattens it with depth 1. You can use Array.prototype.map( ... ).flat(1) instead, but flatMap is usually faster.

flatMap can insert and remove elements to/from an array, which makes this method very powerful!

Example to increment each number in an array, then duplicate every 4:

let numbers = [ 1, 3, 2, 4, 3, 5, 4, 6 ];

numbers.flatMap(n => {
  n++;
  return n === 4 ? [n, n] : n;
})
// returns [ 2, 4, 4, 3, 5, 4, 4, 6, 5, 7 ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.