Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-select): Remove unsupported method in IE #919

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/base/src/config/CalendarType.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const calendarType = getConfiguredCalendarType();

const getCalendarType = () => {
if (calendarType) {
const type = Object.keys(CalendarType).filter(calType => calType === calendarType)[0];
const type = Object.keys(CalendarType).find(calType => calType === calendarType);

if (type) {
return type;
Expand Down
1 change: 1 addition & 0 deletions packages/base/src/features/browsersupport/IE11.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "../../thirdparty/Object.entries.js";

// Array
import "../../thirdparty/Array.prototype.fill.js";
import "../../thirdparty/Array.prototype.find.js";
import "../../thirdparty/Array.prototype.includes.js";

// Number
Expand Down
46 changes: 46 additions & 0 deletions packages/base/src/thirdparty/Array.prototype.find.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// https://tc39.github.io/ecma262/#sec-array.prototype.find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function (predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw TypeError('"this" is null or not defined');
}

var o = Object(this);

// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;

// 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw TypeError('predicate must be a function');
}

// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1];

// 5. Let k be 0.
var k = 0;

// 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
// e. Increase k by 1.
k++;
}

// 7. Return undefined.
return undefined;
},
configurable: true,
writable: true
});
}
2 changes: 1 addition & 1 deletion packages/base/src/util/TabbableElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getTabbables = (nodes, tabbables) => {
if (currentNode.shadowRoot) {
// get the root node of the ShadowDom (1st none style tag)
const children = currentNode.shadowRoot.children;
currentNode = Array.from(children).filter(node => node.tagName !== "STYLE")[0];
currentNode = Array.from(children).find(node => node.tagName !== "STYLE");
}

if (isNodeTabbable(currentNode)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/MultiComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class MultiComboBox extends UI5Element {

_tokenDelete(event) {
const token = event.detail.ref;
const deletingItem = this.items.filter(item => item._id === token.getAttribute("data-ui5-id"))[0];
const deletingItem = this.items.find(item => item._id === token.getAttribute("data-ui5-id"));

deletingItem.selected = false;
this._deleting = true;
Expand Down
14 changes: 7 additions & 7 deletions packages/main/src/ShellBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ class ShellBar extends UI5Element {

this._itemNav.setItemsCallback = items => {
const newItems = that._itemsInfo.map(stateItem => {
const mappingItem = items.filter(item => {
const mappingItem = items.find(item => {
return item.id === stateItem.id;
})[0];
});

const clone = JSON.parse(JSON.stringify(stateItem));
clone._tabIndex = mappingItem ? mappingItem._tabIndex : "-1";
Expand Down Expand Up @@ -483,7 +483,7 @@ class ShellBar extends UI5Element {
const width = this.getBoundingClientRect().width;
const breakpoints = ShellBar.FIORI_3_BREAKPOINTS;

const size = breakpoints.filter(bp1 => width < bp1)[0] || ShellBar.FIORI_3_BREAKPOINTS[ShellBar.FIORI_3_BREAKPOINTS.length - 1];
const size = breakpoints.find(bp1 => width < bp1) || ShellBar.FIORI_3_BREAKPOINTS[ShellBar.FIORI_3_BREAKPOINTS.length - 1];
const mappedSize = ShellBar.FIORI_3_BREAKPOINTS_MAP[size];

if (this.breakpointSize !== mappedSize) {
Expand Down Expand Up @@ -583,11 +583,11 @@ class ShellBar extends UI5Element {
return 1;
});

const focusedItem = items.filter(item => {
const focusedItem = items.find(item => {
return (item.classes.indexOf("ui5-shellbar-invisible-button") === -1)
&& (item.classes.indexOf("ui5-shellbar-overflow-button") === -1)
&& (item.classes.indexOf("ui5-shellbar-hidden-button") === -1);
})[0];
});

return focusedItem;
}
Expand Down Expand Up @@ -680,9 +680,9 @@ class ShellBar extends UI5Element {
this._itemNav.currentIndex = elementIndex;

if (refItemId) {
const shellbarItem = this.items.filter(item => {
const shellbarItem = this.items.find(item => {
return item.shadowRoot.querySelector(`#${refItemId}`);
})[0];
});

const prevented = !shellbarItem.fireEvent("itemClick", { targetRef: event.target }, true);

Expand Down