Giter Club home page Giter Club logo

ent's Introduction

  • 🔭 I’m currently working on https://chuangyi.taobao.com (we're hiring!), a creative platform implemented in JavaScript and Rust.
  • 🌱 I’ve been involved with web stuff for a while, and my own two cents are leoric and porter.

ent's People

Contributors

cyjake avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dlutwuwei

ent's Issues

util.scriptOnload 中不可删除 script 节点

如果 ent.js 中删除掉当前节点,sea.js 中的 scriptOnload 再删的时候会出问题,不过仅在 IE9 中出现,为导致代码执行不下去,但也没有任何错误信息。

相当诡异呃……

升级到 seajs 1.2.0,兼容其 api (用得到的)

之前参考的是 seajs 1.1.1-dev,用了个生僻的 api,require.load,如今在 seajs 1.2.0 版本中,这货直接被去掉了,还是用回 require.async

看闭 1.1 -> 1.2 注意事项,除了上述接口变化之外,其余不足虑,都没有用到,也不需要在精简版中做兼容。

除了 require.async 变化之外,另外一个需要搞定的问题是历史遗留。seajs 里,可以相对当前模块路径 require,例如模块 id 是 cc/templets/foo,则 require('./bar') 便会加载 cc/templets/bar 模块。旧版的 ent 实现时,创意中心的代码都是写模块全名的,因此没有做这方面的兼容。

但这个实现一下很有必要。

ent 与页面上已有 seajs 的比较

ent 里面,现在咱们是通过页面上是否已有 seajs ,来决定是否重载

if (!global.seajs) {
  ...
  global.seajs = _ent
}
else {
    _ent.use = seajs.use
}

理论上,页面上引入的 seajs 都会有一个 seajs 的版本号,如:

seajs.version="2.0.0-dev";

当然,不排除,会有很古老的版本号,就像 TMS 预览页面,比如:

seajs.version="1.0.2";

更甚者,如果被使用者阉割过的,读版本号根本就是个 undefined,但现在 ent 基于:

seajs.version = "1.2.0";

这个版本,引入到一个 seajs 存在与版本都未知的宿主页面,难免会埋下一些坑,比如 页面上的 seajs 版本陈旧,那我们的模板可能就不展现,比如 TMS 预览时候,或者页面上使用方对 seajs 做了异步加载等,可能此时模板中的 _ent 已经载入,会提前侵蚀掉 seajs 这个全局变量,也会引发一些未知的问题。

我觉得这里可以通过两种途径来权衡:

  1. 不论页面上是否有 seajs ,版本是新还是旧,我们只用 _ent,同时 _ent 也不再替代 seajs,即:

    //global.seajs = _ent;
    //_ent.use = seajs.use
    以及这个外围判断都不必有了,_entseajs 各自独立的,不过这里的 global.define 是否也需要改造呢?

  2. 利用 seajs 版本号做判断,如果是和 _ent兼容稳定的版本,就用,否则就不用,不过这个是稍微有点蛋疼,而且依旧不能避免特殊场景下 侵蚀掉 seajs 的情况。

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.