polyfills

How do I make toLowerCase() and toUpperCase() consistent across browsers

心已入冬 提交于 2019-12-01 06:02:58
问题 Are there JavaScript polyfill implementations of String.toLowerCase() and String.toUpperCase(), or other methods in JavaScript that can work with Unicode characters and are consistent across browsers? Background info Performing the following will give difference results in browsers, or even between browser versions (E.g FireFox 54 vs 55): document.write(String.fromCodePoint(223).normalize("NFKC").toLowerCase().toUpperCase().toLowerCase()) In Firefox 55 it gives you ss , in Firefox 54 it gives

Comparing a variable with itself

你。 提交于 2019-12-01 04:15:33
I stumbled over this polyfill of Array.prototype.includes. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes . Is there a reason for the comparison of the variables with themselves on line 21,22? if (searchElement === currentElement || (searchElement !== searchElement && currentElement !== currentElement)) { return true; } Bergi Yes, this second operand of the || does check whether both searchElement and currentElement are NaN - the only value in JavaScript that is not === to itself. includes is supposed to use the SameValueZero equivalence

FileReader.js nothing happens in IE9

允我心安 提交于 2019-12-01 04:13:49
问题 I need help setting up Jadriens FileReader.js. I have set up everything as I think this polyfill works. But the callback that fires when everything is initiated doesn't fire in IE9. This is my markup: <body> <div class="main"> <canvas id="mainCanvas" width="600" height="600"></canvas><br /> <div id="fileReaderSWFObject"></div> <input type="file" id="imageLoader" name="imageLoader" /><br /> <input id="text" type="text" placeholder="some text..."> </div> <script src="//ajax.googleapis.com/ajax

Using ApolloClient with node.js. “fetch is not found globally and no fetcher passed”

…衆ロ難τιáo~ 提交于 2019-12-01 02:53:30
I am attempting to use an Apollo Client on a node.js server to interface with another GraphQL API using the following code: import fetch from 'node-fetch' import { createHttpLink } from 'apollo-link-http' import ApolloClient from 'apollo-boost' import { API_URL } from '...' const client = new ApolloClient({ link: createHttpLink({ uri: API_URL, fetch: fetch, }), }) Which yields the following error: module initialization error: Error fetch is not found globally and no fetcher passed, to fix pass a fetch for your environment like https://www.npmjs.com/package/node-fetch. For example: import fetch

Using ApolloClient with node.js. “fetch is not found globally and no fetcher passed”

我们两清 提交于 2019-11-30 22:44:17
问题 I am attempting to use an Apollo Client on a node.js server to interface with another GraphQL API using the following code: import fetch from 'node-fetch' import { createHttpLink } from 'apollo-link-http' import ApolloClient from 'apollo-boost' import { API_URL } from '...' const client = new ApolloClient({ link: createHttpLink({ uri: API_URL, fetch: fetch, }), }) Which yields the following error: module initialization error: Error fetch is not found globally and no fetcher passed, to fix

Enable support for CSS3 ::outside pseudoelement

流过昼夜 提交于 2019-11-30 17:59:04
I'd like to be able to use the ::outside pseudoelement, but apparently none of the major browsers support it (based on my testing today). Is there some kind of JS polyfill that enables this selector? Or is there a good technique for simulating this? You are correct: no browser in existence has implemented any of the new features in the ancient CSS3 Generated and Replaced Content module , so you won't be able to try the proposed pseudo-elements. In fact, they're planning to rewrite the module itself, so the current working draft should be considered abandoned, and unfortunately there's no

CSS Background Sizing Polyfill?

大憨熊 提交于 2019-11-30 17:18:30
Is there a polyfill to handle CSS Background Sizing in Safari 4 (iOS) and IE could try this. http://nooshu.com/jquery-plug-in-scalable-background-image I'm in the process of looking as well. lockedown Allegedly this is a polyfill on GitHUb that enables CSS3 Background Size to work, but I'm still having issues figuring it out myself. https://github.com/louisremi/background-size-polyfill Let me know if you get it to work. I'm looking for something similar. 来源: https://stackoverflow.com/questions/7572432/css-background-sizing-polyfill

MDN Function.prototype.bind bound function called as constructor

邮差的信 提交于 2019-11-30 16:40:29
I know that when a function returned by Function.prototype.bind is called as a constructor, the pre-bound this is ignored. This is the behaviour specified in ECMA-262, and the behaviour that MDN polyfill implements. My question is: how that polyfill works in that case? I know that this code is responsoble for that: fNOP = function () {} and return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, and fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); But why do they need to create this dummy function ( fNOP ), instantiate it and assign to the fBound 's prototype and so

MDN Function.prototype.bind bound function called as constructor

浪尽此生 提交于 2019-11-30 16:19:04
问题 I know that when a function returned by Function.prototype.bind is called as a constructor, the pre-bound this is ignored. This is the behaviour specified in ECMA-262, and the behaviour that MDN polyfill implements. My question is: how that polyfill works in that case? I know that this code is responsoble for that: fNOP = function () {} and return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, and fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); But why do they

HTML Templates JavaScript polyfills

99封情书 提交于 2019-11-30 13:44:28
问题 I'm looking for the most standards-compliant / future-proof method for front-end HTML templating. There exists a relatively new W3C draft specification for HTML Templates, e.g.: <template id="mytemplate"> <img src="" alt="great image"> <div class="comment"></div> </template> Does anyone know if any good JavaScript polyfills already exist to make <template> element usable in a cross-browser way? Preferably complying with this standard. Difficulties According the the HTML5Rocks guide these