Javascript (gs.left!=(t=left&“px”)和(gs.left=t)做什么?

Javascript (gs.left!=(t=left&“px”)和(gs.left=t)做什么?,javascript,internet-explorer,raphael,Javascript,Internet Explorer,Raphael,IE似乎被未压缩的raphaeljs 1.4.7中的第2207行(当然,在我的代码上下文中)阻塞了: 我不熟悉所以我发现很难弄清楚到底发生了什么,或者IE为什么会不高兴。我已经在IE6和IE8以及OSX上的Chrome和Firefox上进行了测试。当然,如果在FF中出现问题,我会逐步使用firebug 你能告诉我这条线想要达到什么目的吗?更妙的是,你能理解为什么IE可能会有问题吗 对于您的上下文,下面是包含该行的完整方法: Element[proto].setBox = function

IE似乎被未压缩的raphaeljs 1.4.7中的第2207行(当然,在我的代码上下文中)阻塞了:

我不熟悉所以我发现很难弄清楚到底发生了什么,或者IE为什么会不高兴。我已经在IE6和IE8以及OSX上的Chrome和Firefox上进行了测试。当然,如果在FF中出现问题,我会逐步使用firebug

你能告诉我这条线想要达到什么目的吗?更妙的是,你能理解为什么IE可能会有问题吗

对于您的上下文,下面是包含该行的完整方法:

    Element[proto].setBox = function (params, cx, cy) {
        if (this.removed) {
            return this;
        }
        var gs = this.Group.style,
            os = (this.shape && this.shape.style) || this.node.style;
        params = params || {};
        for (var i in params) if (params[has](i)) {
            this.attrs[i] = params[i];
        }
        cx = cx || this._.rt.cx;
        cy = cy || this._.rt.cy;
        var attr = this.attrs,
            x,
            y,
            w,
            h;
        switch (this.type) {
            case "circle":
                x = attr.cx - attr.r;
                y = attr.cy - attr.r;
                w = h = attr.r * 2;
                break;
            case "ellipse":
                x = attr.cx - attr.rx;
                y = attr.cy - attr.ry;
                w = attr.rx * 2;
                h = attr.ry * 2;
                break;
            case "image":
                x = +attr.x;
                y = +attr.y;
                w = attr.width || 0;
                h = attr.height || 0;
                break;
            case "text":
                this.textpath.v = ["m", round(attr.x), ", ", round(attr.y - 2), "l", round(attr.x) + 1, ", ", round(attr.y - 2)][join](E);
                x = attr.x - round(this.W / 2);
                y = attr.y - this.H / 2;
                w = this.W;
                h = this.H;
                break;
            case "rect":
            case "path":
                if (!this.attrs.path) {
                    x = 0;
                    y = 0;
                    w = this.paper.width;
                    h = this.paper.height;
                } else {
                    var dim = pathDimensions(this.attrs.path);
                    x = dim.x;
                    y = dim.y;
                    w = dim.width;
                    h = dim.height;
                }
                break;
            default:
                x = 0;
                y = 0;
                w = this.paper.width;
                h = this.paper.height;
                break;
        }
        cx = (cx == null) ? x + w / 2 : cx;
        cy = (cy == null) ? y + h / 2 : cy;
        var left = cx - this.paper.width / 2,
            top = cy - this.paper.height / 2, t;
        gs.left != (t = left + "px") && (gs.left = t);
        gs.top != (t = top + "px") && (gs.top = t);
        this.X = pathlike[has](this.type) ? -left : x;
        this.Y = pathlike[has](this.type) ? -top : y;
        this.W = w;
        this.H = h;
        if (pathlike[has](this.type)) {
            os.left != (t = -left * zoom + "px") && (os.left = t);
            os.top != (t = -top * zoom + "px") && (os.top = t);
        } else if (this.type == "text") {
            os.left != (t = -left + "px") && (os.left = t);
            os.top != (t = -top + "px") && (os.top = t);
        } else {
            gs.width != (t = this.paper.width + "px") && (gs.width = t);
            gs.height != (t = this.paper.height + "px") && (gs.height = t);
            os.left != (t = x - left + "px") && (os.left = t);
            os.top != (t = y - top + "px") && (os.top = t);
            os.width != (t = w + "px") && (os.width = t);
            os.height != (t = h + "px") && (os.height = t);
        }
    };

这行代码没有问题-假设定义了
gs.left
left
。这相当于:

t = left + 'px';
if (gs.left != t) gs.left = t;

你所说的“窒息”到底是什么意思?

这行代码没有错——假设定义了
gs.left
left
。这相当于:

t = left + 'px';
if (gs.left != t) gs.left = t;

“窒息”到底是什么意思?

谢谢你。我不是说这行代码有什么问题,我只是想理解它。IE在页面上报告了一个模棱两可的错误:当其他浏览器继续运行时,这行的参数无效。明白了。所以我最好的猜测是,在IE中,“gs”并没有被定义为调用堆栈中具有“left”属性的对象。我会先提醒“gs”,“gs.left”和“left”,以确保你在致命线前得到了你应该得到的东西。谢谢byoogle。我不是说这行代码有什么问题,我只是想理解它。IE在页面上报告了一个模棱两可的错误:当其他浏览器继续运行时,这行的参数无效。明白了。所以我最好的猜测是,在IE中,“gs”并没有被定义为调用堆栈中具有“left”属性的对象。我会先提醒“gs”、“gs.left”和“left”,以确保你在致命线前得到了你应该得到的东西。