For loops have been refactored to use more idiomatic JavaScript functions (filter(), some(), forEach()) where appropriate.
Details
- Reviewers
mart - Group Reviewers
Kirigami - Commits
- R169:6a0535050b8c: Refactor for loops
Ensure no regressions in modified components
Diff Detail
- Repository
- R169 Kirigami
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
I'm not a Javascript expert, but the old/current versions seem much more readable to me. Is there a performance advantage to your proposed new versions?
+1 for the .some() use
-1 on the convoluted Array.prototype things, especially when chained.
src/controls/Action.qml | ||
---|---|---|
156 | Why are you going through the prototype? Or is children not a "proper" Array? | |
src/controls/FormLayout.qml | ||
83–84 | Looks like a usecas for Array.reduce? | |
src/controls/templates/private/PassiveNotification.qml | ||
62–63 | I would like a comment here. Note veryone is faimilar with slice in that fashion. | |
73–75 | Why no arrow function? |
src/controls/Action.qml | ||
---|---|---|
156 | It's a QML list, not an ECMAScript Array. Also, I don't see why you would need to use the spread operator here. |
No, the main point is writing idiomatic JavaScript. To people familiar with idiomatic JavaScript, these constructs will immediately let them know what's going on instead of them having to parse a multiline structure.
This appears to have broken SwipeListItem. Now the actions don't show up anymore and there's loads of console spam:
file:///home/nate/kde/usr/lib64/qml/org/kde/kirigami.2/templates/SwipeListItem.qml:421: TypeError: Type error file:///home/nate/kde/usr/lib64/qml/org/kde/kirigami.2/templates/SwipeListItem.qml:421: TypeError: Type error file:///home/nate/kde/usr/lib64/qml/org/kde/kirigami.2/templates/SwipeListItem.qml:421: TypeError: Type error
Might want to check everything else too.