Skip to content

Commit

Permalink
Fix #4129 (for in)
Browse files Browse the repository at this point in the history
  • Loading branch information
100pah committed Sep 23, 2016
1 parent 6948f45 commit c770b51
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/CoordinateSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ define(function(require) {
create: function (ecModel, api) {
var coordinateSystems = [];
for (var type in coordinateSystemCreators) {
var list = coordinateSystemCreators[type].create(ecModel, api);
list && (coordinateSystems = coordinateSystems.concat(list));
if (coordinateSystemCreators.hasOwnProperty(type)) {
var list = coordinateSystemCreators[type].create(ecModel, api);
list && (coordinateSystems = coordinateSystems.concat(list));
}
}

this._coordinateSystems = coordinateSystems;
Expand Down
2 changes: 1 addition & 1 deletion src/chart/helper/WhiskerBoxDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define(function (require) {

buildPath: function (ctx, shape) {
for (var i in shape) {
if (i.indexOf('ends') === 0) {
if (shape.hasOwnProperty(i) && i.indexOf('ends') === 0) {
var pts = shape[i];
ctx.moveTo(pts[0][0], pts[0][1]);
ctx.lineTo(pts[1][0], pts[1][1]);
Expand Down
4 changes: 2 additions & 2 deletions src/component/legend/LegendModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ define(function(require) {
toggleSelected: function (name) {
var selected = this.option.selected;
// Default is true
if (!(name in selected)) {
if (!selected.hasOwnProperty(name)) {
selected[name] = true;
}
this[selected[name] ? 'unSelect' : 'select'](name);
Expand All @@ -125,7 +125,7 @@ define(function(require) {
*/
isSelected: function (name) {
var selected = this.option.selected;
return !((name in selected) && !selected[name])
return !(selected.hasOwnProperty(name) && !selected[name])
&& zrUtil.indexOf(this._availableNames, name) >= 0;
},

Expand Down
6 changes: 4 additions & 2 deletions src/component/marker/MarkerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ define(function (require) {
render: function (markerModel, ecModel, api) {
var markerGroupMap = this.markerGroupMap;
for (var name in markerGroupMap) {
markerGroupMap[name].__keep = false;
if (markerGroupMap.hasOwnProperty(name)) {
markerGroupMap[name].__keep = false;
}
}

var markerModelKey = this.type + 'Model';
Expand All @@ -26,7 +28,7 @@ define(function (require) {
}, this);

for (var name in markerGroupMap) {
if (!markerGroupMap[name].__keep) {
if (markerGroupMap.hasOwnProperty(name) && !markerGroupMap[name].__keep) {
this.group.remove(markerGroupMap[name].group);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/visualMap/PiecewiseModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ define(function(require) {
// Consider 'not specified' means true.
zrUtil.each(pieceList, function (piece, index) {
var key = this.getSelectedMapKey(piece);
if (!(key in selected)) {
if (!selected.hasOwnProperty(key)) {
selected[key] = true;
}
}, this);
Expand Down
12 changes: 8 additions & 4 deletions src/coord/cartesian/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ define(function(require, factory) {
function ifAxisCanNotOnZero(otherAxisDim) {
var axes = axesMap[otherAxisDim];
for (var idx in axes) {
var axis = axes[idx];
if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
return true;
if (axes.hasOwnProperty(idx)) {
var axis = axes[idx];
if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -191,7 +193,9 @@ define(function(require, factory) {
if (axisIndex == null) {
// Find first axis
for (var name in axesMapOnDim) {
return axesMapOnDim[name];
if (axesMapOnDim.hasOwnProperty(name)) {
return axesMapOnDim[name];
}
}
}
return axesMapOnDim[axisIndex];
Expand Down
13 changes: 7 additions & 6 deletions src/echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ define(function (require) {
var bottom = -MAX_NUMBER;
var canvasList = [];
var dpr = (opts && opts.pixelRatio) || 1;
for (var id in instances) {
var chart = instances[id];

zrUtil.each(instances, function (chart, id) {
if (chart.group === groupId) {
var canvas = chart.getRenderedCanvas(
zrUtil.clone(opts)
Expand All @@ -385,7 +385,7 @@ define(function (require) {
top: boundingRect.top
});
}
}
});

left *= dpr;
top *= dpr;
Expand Down Expand Up @@ -1218,12 +1218,13 @@ define(function (require) {
if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
var action = chart.makeActionFromEvent(event);
var otherCharts = [];
for (var id in instances) {
var otherChart = instances[id];

zrUtil.each(instances, function (otherChart) {
if (otherChart !== chart && otherChart.group === chart.group) {
otherCharts.push(otherChart);
}
}
});

updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
each(otherCharts, function (otherChart) {
if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
Expand Down
12 changes: 6 additions & 6 deletions src/model/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,21 +564,21 @@ define(function (require) {
* @inner
*/
function mergeTheme(option, theme) {
for (var name in theme) {
zrUtil.each(theme, function (themeItem, name) {
// 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
if (!ComponentModel.hasClass(name)) {
if (typeof theme[name] === 'object') {
if (typeof themeItem === 'object') {
option[name] = !option[name]
? zrUtil.clone(theme[name])
: zrUtil.merge(option[name], theme[name], false);
? zrUtil.clone(themeItem)
: zrUtil.merge(option[name], themeItem, false);
}
else {
if (option[name] == null) {
option[name] = theme[name];
option[name] = themeItem;
}
}
}
}
});
}

function initBase(baseOption) {
Expand Down
4 changes: 3 additions & 1 deletion src/util/symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ define(function(require) {

var symbolBuildProxies = {};
for (var name in symbolCtors) {
symbolBuildProxies[name] = new symbolCtors[name]();
if (symbolCtors.hasOwnProperty(name)) {
symbolBuildProxies[name] = new symbolCtors[name]();
}
}

var Symbol = graphic.extendShape({
Expand Down
2 changes: 1 addition & 1 deletion src/visual/VisualMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ define(function (require) {

if (!isCategory
&& visualArr.length === 1
&& !(thisOption.type in doNotNeedPair)
&& !doNotNeedPair.hasOwnProperty(thisOption.type)
) {
// Do not care visualArr.length === 0, which is illegal.
visualArr[1] = visualArr[0];
Expand Down

0 comments on commit c770b51

Please sign in to comment.