V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
kevinroot
V2EX  ›  问与答

zeptojs 为毛最后不给加个分号

  •  
  •   kevinroot · May 8, 2014 · 3301 views
    This topic created in 4384 days ago, the information mentioned may be changed or developed.
    http://zeptojs.com/zepto.js
    他的规范貌似是分号写在开头,这样我combo js的时候就报错了
    ;(function($){
    // __proto__ doesn't exist on IE<11, so redefine
    // the Z function to use object extension instead
    if (!('__proto__' in {})) {
    $.extend($.zepto, {
    Z: function(dom, selector){
    dom = dom || []
    $.extend(dom, $.fn)
    dom.selector = selector || ''
    dom.__Z = true
    return dom
    },
    // this is a kludge but works
    isZ: function(object){
    return $.type(object) === 'array' && '__Z' in object
    }
    })
    }

    // getComputedStyle shouldn't freak out when called
    // without a valid element as argument
    try {
    getComputedStyle(undefined)
    } catch(e) {
    var nativeGetComputedStyle = getComputedStyle;
    window.getComputedStyle = function(element){
    try {
    return nativeGetComputedStyle(element)
    } catch(e) {
    return null
    }
    }
    }
    })(Zepto)var myvar = 'test';
    8 replies    2014-05-08 11:00:18 +08:00
    likang
        1
    likang  
       May 8, 2014
    combo 的时候统一加换行符呢?
    kevinroot
        2
    kevinroot  
    OP
       May 8, 2014
    @likang 这样应该是可以的,不过现在combo没有加换行的机制
    zythum
        3
    zythum  
       May 8, 2014
    你拿压缩混淆的版本不就可以了...
    kevinroot
        4
    kevinroot  
    OP
       May 8, 2014
    @zythum 他最新版的可以
    http://zeptojs.com/zepto.min.js
    我们的版本是压缩的还是不行
    http://s.thsi.cn/js/m/js/zepto.min.js
    jsonline
        5
    jsonline  
       May 8, 2014
    你也要在最开头加分号
    kevinroot
        6
    kevinroot  
    OP
       May 8, 2014
    @jsonline 这不符合我们的编码规范 - -!
    jsonline
        7
    jsonline  
       May 8, 2014
    @kevinroot combo 在连接的时候每个文件之间加分号
    zzNucker
        8
    zzNucker  
       May 8, 2014
    @kevinroot 本来就是在开头加分号比较多吧 - -
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2790 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 01:42 · PVG 09:42 · LAX 18:42 · JFK 21:42
    ♥ Do have faith in what you're doing.