CreateJS / EaselJS

The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
http://createjs.com/
MIT License
8.11k stars 1.97k forks source link

2.0.0-beta.2 fails to new Stage #987

Closed MarvinWilliam closed 5 years ago

MarvinWilliam commented 5 years ago

TODO

Issue Details

import { Stage } from '@createjs/easeljs';

export default class Canvas {
    constructor() {
        this.stage = new Stage('canvasId');
    }
}

Error:

easeljs.module.js:1904 Uncaught TypeError: Illegal constructor
    at createCanvas (easeljs.module.js:1904)
    at Object../node_modules/@createjs/easeljs/dist/easeljs.module.js (easeljs.module.js:3160)
    at __webpack_require__ (bootstrap 8cba5b6e973429fc89a0:678)

code where throw error

function createCanvas(width = 1, height = 1) {
  let c;
  if (window.createjs !== undefined && window.createjs.createCanvas !== undefined) {
    c = window.createjs.createCanvas();
  }
  if (HTMLCanvasElement) {
    // this line throw error "Illegal constructor"
    c = new HTMLCanvasElement();
  }
  if (c !== undefined) {
    c.width = width;
    c.height = height;
    return c;
  }
  throw "Canvas not supported in this environment.";
}
MarvinWilliam commented 5 years ago

This my pr for this issue. https://github.com/CreateJS/EaselJS/pull/988#issue-219197170

txiaocao commented 5 years ago

这个问题依然存在,使得无法在浏览器当中使用easeljs@2.0.0-beta3。什么时候能够发布一个新的版本修复这个问题呢?

This problem still exists, which makes it impossible to use easeljs@2.0.0-beta3 in browsers. When can we release a new version to fix this problem?

tehvgg commented 5 years ago

Fixed in beta.4