Estou usando o TRÊS em um projeto Aurelia-CLI. Isso significa que é carregado usando módulos e RequireJS. Funciona bem, exceto no Internet Explorer (testado no IE 11).
O código que quebra é o seguinte (na seção polyfill no topo, linhas 42-57) no arquivo /build/three.js
if ( Function.prototype.name === undefined ) {
// Missing in IE
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
Object.defineProperty( Function.prototype, 'name', {
get: function () {
return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ];
}
} );
}
Ele retorna o erro can't redefine non-configurable property "name"
.
Após esta postagem , tentei substituir o código acima por:
if (!(function f() {}).name) {
Object.defineProperty(Function.prototype, 'name', {
get: function() {
var name = (this.toString().match(/^function\s*([^\s(]+)/) || [])[1];
// For better performance only parse once, and then cache the
// result through a new accessor for repeated access.
Object.defineProperty(this, 'name', { value: name });
return name;
}
});
}
E isso resolve o problema!
=> Parece que o código polyfill usado atualmente em /build/three.js não funciona bem. É possível substituir este código para compilações futuras?
Mudar o cheque para isso faria alguma diferença?
if ( 'name' in Function.prototype === false ) {
Ou
if ( Function.prototype.hasOwnProperty( 'name' ) === false ) {
Eu confirmo que apenas mudar if
é o suficiente.
if ( 'name' in Function.prototype === false ) {
é o caminho a seguir!
Fixo. Obrigado!
Comentários muito úteis
Eu confirmo que apenas mudar
if
é o suficiente.é o caminho a seguir!