From f87151a44e673dac125404fb1c8809679f390aef Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Mon, 12 Oct 2020 09:58:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E4=BF=AE=E5=A4=8Dif?= =?UTF-8?q?rame=20attributes=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this.options = extend(this._defaultConfig(config), props, config); options的生成是浅extend,如果外部也传了attributes 属性就被覆盖了 --- src/base/single/iframe/iframe.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/base/single/iframe/iframe.js b/src/base/single/iframe/iframe.js index 49daf5715..69d131b65 100644 --- a/src/base/single/iframe/iframe.js +++ b/src/base/single/iframe/iframe.js @@ -12,18 +12,17 @@ BI.Iframe = BI.inherit(BI.Single, { baseCls: (conf.baseCls || "") + " bi-iframe", src: "", name: "", - attributes: { - frameborder: 0, - src: config.src, - name: config.name - }, + attributes: {}, width: "100%", height: "100%" }); }, _init: function () { - var self = this; + var self = this, o = this.options; + o.attributes.frameborder = "0"; + o.attributes.src = o.src; + o.attributes.name = o.name; BI.Iframe.superclass._init.apply(this, arguments); this.element.on("load", function () { self.fireEvent("EVENT_LOADED"); From 6ec99d0da0ff993fe345fe5ffe73e82b02007da9 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Mon, 12 Oct 2020 10:44:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E4=BF=AE=E5=A4=8Dat?= =?UTF-8?q?tributes=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98=20=20=5FinitProps?= =?UTF-8?q?=20=20=20this.options=20=3D=20extend(this.=5FdefaultConfig(conf?= =?UTF-8?q?ig),=20props,=20config);=20=E6=98=AF=E6=B5=85extend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/iframe/iframe.js | 8 +++++--- src/base/single/img/img.js | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/base/single/iframe/iframe.js b/src/base/single/iframe/iframe.js index 69d131b65..d87265708 100644 --- a/src/base/single/iframe/iframe.js +++ b/src/base/single/iframe/iframe.js @@ -20,10 +20,12 @@ BI.Iframe = BI.inherit(BI.Single, { _init: function () { var self = this, o = this.options; - o.attributes.frameborder = "0"; - o.attributes.src = o.src; - o.attributes.name = o.name; BI.Iframe.superclass._init.apply(this, arguments); + this.element.attr(BI.extend({ + frameborder: 0, + src: o.src, + name: o.name + }, o.attributes)); this.element.on("load", function () { self.fireEvent("EVENT_LOADED"); }); diff --git a/src/base/single/img/img.js b/src/base/single/img/img.js index e54306b11..670b16649 100644 --- a/src/base/single/img/img.js +++ b/src/base/single/img/img.js @@ -13,12 +13,17 @@ BI.Img = BI.inherit(BI.Single, { tagName: "img", baseCls: (conf.baseCls || "") + " bi-img display-block", src: "", - attributes: config.src ? {src: config.src} : {}, + attributes: config.src ? { src: config.src } : {}, width: "100%", height: "100%" }); }, + _init: function () { + BI.Img.superclass._init.apply(this, arguments); + this.setSrc(this.options.src); + }, + setSrc: function (src) { this.options.src = src; this.element.attr("src", src); From e445120f834ce5de2b21bc6c577a5e1451bbbcf3 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Mon, 12 Oct 2020 11:23:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E4=BF=AE=E5=A4=8Dif?= =?UTF-8?q?rame=20attributes=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/iframe/iframe.js | 17 +++++++++++------ src/base/single/img/img.js | 9 ++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/base/single/iframe/iframe.js b/src/base/single/iframe/iframe.js index d87265708..7aee46064 100644 --- a/src/base/single/iframe/iframe.js +++ b/src/base/single/iframe/iframe.js @@ -19,18 +19,23 @@ BI.Iframe = BI.inherit(BI.Single, { }, _init: function () { - var self = this, o = this.options; + var self = this; BI.Iframe.superclass._init.apply(this, arguments); - this.element.attr(BI.extend({ - frameborder: 0, - src: o.src, - name: o.name - }, o.attributes)); this.element.on("load", function () { self.fireEvent("EVENT_LOADED"); }); }, + _initProps: function () { + BI.Iframe.superclass._initProps.apply(this, arguments); + var o = this.options; + this.options.attributes = BI.extend({ + frameborder: 0, + src: o.src, + name: o.name + }, this.options.attributes); + }, + setSrc: function (src) { this.options.src = src; this.element.attr("src", src); diff --git a/src/base/single/img/img.js b/src/base/single/img/img.js index 670b16649..aa90aaf40 100644 --- a/src/base/single/img/img.js +++ b/src/base/single/img/img.js @@ -19,9 +19,12 @@ BI.Img = BI.inherit(BI.Single, { }); }, - _init: function () { - BI.Img.superclass._init.apply(this, arguments); - this.setSrc(this.options.src); + _initProps: function () { + BI.Img.superclass._initProps.apply(this, arguments); + var o = this.options; + this.options.attributes = BI.extend({ + src: o.src + }, this.options.attributes); }, setSrc: function (src) {