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

uint8-array shim breaks native Uint8Array inheritance on Safari #683

Closed
ashi009 opened this issue Oct 31, 2019 · 1 comment
Closed

uint8-array shim breaks native Uint8Array inheritance on Safari #683

ashi009 opened this issue Oct 31, 2019 · 1 comment

Comments

@ashi009
Copy link

ashi009 commented Oct 31, 2019

I created the following snippet to demonstrate the issue. The code then being down leveled with babel (present-env targeting browsers >1%) and bundled with rollup.

Please find the source at https://github.com/ashi009/corejs-typedarray-bug-on-safari.

class A extends Uint8Array {}
class B extends Uint8Array {}
const a = new A(1);
console.log(a instanceof A, a instanceof B, a instanceof Uint8Array);
// should log true, false, true
// Safari logs false, false, tru

The final bundle looks as follow:

var bundle = (function () {
	'use strict';
	
	// omitted core-js modules
    // omitted babel helpers

	var A =
	/*#__PURE__*/
	function (_Uint8Array) {
	  _inherits(A, _Uint8Array);

	  function A() {
	    _classCallCheck(this, A);

	    return _possibleConstructorReturn(this, _getPrototypeOf(A).apply(this, arguments));
	  }

	  return A;
	}(_wrapNativeSuper(Uint8Array));

	var B =
	/*#__PURE__*/
	function (_Uint8Array2) {
	  _inherits(B, _Uint8Array2);

	  function B() {
	    _classCallCheck(this, B);

	    return _possibleConstructorReturn(this, _getPrototypeOf(B).apply(this, arguments));
	  }

	  return B;
	}(_wrapNativeSuper(Uint8Array));

	var a = new A(1);
	console.log(a instanceof A, a instanceof B, a instanceof Uint8Array); // should log true, false, true
	// Safari logs false, false, true

	var babel_out = {

	};

	return babel_out;

}());

This final bundle works fine on Chrome and Firefox. But not Safari. As Safari is ES6 compatible, so I removed all the core-js modules in babel output and bundled it again, as a result, Safari also prints the right output.

Then I put core-js modules back in one by one and found the culprit is core-js/modules/es.typed-array.uint8-array.

To be clear, this is tested with core-js 3.3.5. Please see the package.json and yarn.lock in the linked repo for the complete dependency.

@majksner
Copy link

majksner commented Dec 2, 2019

I'm still experiencing this issue in Safari with the latest version of core-js.

Removing code below fixes the issue.

import 'core-js'
import 'regenerator-runtime/runtime'

Screen Shot 2019-12-02 at 15 08 00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants