Skip to content

Commit

Permalink
Merge pull request #132 from tedious/private_methods
Browse files Browse the repository at this point in the history
Support private methods
  • Loading branch information
tedivm authored Apr 18, 2023
2 parents aa786b1 + bab7c39 commit e72133d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
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)}}

0 comments on commit e72133d

Please sign in to comment.