-
Notifications
You must be signed in to change notification settings - Fork 2.7k
luci-theme-*: use ES6 syntax #8092
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
Conversation
|
Hi @systemcrash , do you think this update is necessary? |
|
Please split this PR in several commits for each theme. |
Done. |
feckert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not so familiar with the newest javascript. But what does this mean new arrow function? Can you give me more context about that?
themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js
Show resolved
Hide resolved
themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js
Outdated
Show resolved
Hide resolved
themes/luci-theme-bootstrap/htdocs/luci-static/resources/view/bootstrap/sysauth.js
Outdated
Show resolved
Hide resolved
Sure. In ES6, arrow functions don’t create their own In this code: return baseclass.extend({
__init__() {
ui.menu.load().then((tree) => this.render(tree));
},
});the arrow function inherits ui.menu.load().then(L.bind(this.render, this));The change simply removes the need for the custom |
Replaced L.bind with arrow functions, used Array.from for array conversion, applied concise method syntax, and switched to block-scoped declarations. Signed-off-by: Eamon Xiong <[email protected]>
Replaced L.bind with an arrow function for simpler syntax and clearer `this` binding. Signed-off-by: Eamon Xiong <[email protected]>
Replaced L.bind with an arrow function for simpler syntax and clearer `this` binding. Signed-off-by: Eamon Xiong <[email protected]>
Replaced L.bind with an arrow function for simpler syntax and clearer `this` binding. Signed-off-by: Eamon Xiong <[email protected]>
|
@eamonxg Thanks for your explanation. |
|
@feckert - you can safely rely on ES6 features now, other parts of LuCI, mainly luci-base, already require them anyway. |
|
Yes @feckert ES6 is fine. Some places even use newer standards… |
|
Thanks for the clarification. |
|
@eamonxg Thanks merged |
Updated to arrow functions for clearer
thisbinding, replaced slice.call with Array.from for more readable array conversion, and adopted ES6 block-scoped declarations.Signed-off-by: <[email protected]>row (viagit commit --signoff)<package name>: titlefirst line subject for packagesPKG_VERSIONin the Makefile