diffConfig always returns true if modeBarButtons (array of array) is populated
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 18.3k
- Fork
- 2k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 28
Mô tả
diffConfig function has bug where it always returns true if modeBarButtons (array of array) is populated. This results in unnecessary re-rendering. The function should check if the array member is array inside a for loop, It should be -
/*
-
simple diff for config - for now, just treat all changes as equivalent
*/
function diffConfig(oldConfig, newConfig) {
var key;for(key in oldConfig) {
if(key.charAt(0) === '_') continue;
var oldVal = oldConfig[key];
var newVal = newConfig[key];
if(oldVal !== newVal) {
if(Lib.isPlainObject(oldVal) && Lib.isPlainObject(newVal)) {
if(diffConfig(oldVal, newVal)) {
return true;
}
} else if(Array.isArray(oldVal) && Array.isArray(newVal)) {
if(oldVal.length !== newVal.length) {
return true;
}for(var i = 0; i < oldVal.length; i++) { if(oldVal[i] !== newVal[i]) { **if(Array.isArray(oldVal[i]) && Array.isArray(newVal[i])){ if(diffConfig(oldVal[i], newVal[i])) { return true; } } else** if(Lib.isPlainObject(oldVal[i]) && Lib.isPlainObject(newVal[i])) { if(diffConfig(oldVal[i], newVal[i])) { return true; } } else { return true; } } } } else { return true; } }}
}
e.g Config object used -
const plotlyConfig: Partial = {
responsive: true,
displaylogo: false,
displayModeBar: true,
doubleClick: false,
showTips: false,
scrollZoom: false,
modeBarButtons: [
[
'select2d',
'lasso2d',
'zoom2d',
'pan2d',
'resetScale2d',
],
],
locale: language,
locales: locales
}
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tìm hàm diffConfig và sử dụng ví dụ plotlyConfig với các mảng modeBarButtons lồng nhau làm trường hợp tái hiện. So sánh các mảng lồng nhau tương đương và xác minh rằng các cấu hình không thay đổi không bị báo cáo là khác nhau, tránh việc render lại không cần thiết; issue không nêu tệp hoặc test nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- data-visualization, frontend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100