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

Support private methods #132

Merged
merged 1 commit into from
Apr 18, 2023
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
1 change: 1 addition & 0 deletions src/JShrink/Minifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ protected function initialize($js, $options)
'-' => true,
'+' => true,
'[' => true,
'#' => true,
'@' => true];


Expand Down
30 changes: 30 additions & 0 deletions tests/Resources/jshrink/input/private_methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default class Example {
#prop

set prop (value) {
this.#prop = value

this.#event(value)
}
get prop () {
return this.#prop
}

constructor (arg) {
this.#prop = arg

if (arg) {
this.#method()
}
}

#event = f => {
if (typeof f === 'function') {
f()
}
}

#method = async _ => {
return fetch(param)
}
}
8 changes: 8 additions & 0 deletions tests/Resources/jshrink/output/private_methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default class Example{#prop
set prop(value){this.#prop=value
this.#event(value)}
get prop(){return this.#prop}
constructor(arg){this.#prop=arg
if(arg){this.#method()}}
#event=f=>{if(typeof f==='function'){f()}}
#method=async _=>{return fetch(param)}}