Code Monkey home page Code Monkey logo

jsmin-php's People

Contributors

acidvertigo avatar apeschar avatar glensc avatar hjtappe avatar icetee avatar joec4i avatar joscha avatar jrchamp avatar kendallhopkins avatar meven avatar mrclay avatar plus-robertehrenleitner avatar rgrove avatar robations avatar simonsimcity avatar tubalmartin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsmin-php's Issues

template literals and handling of missing semi-colons

When normal JS vars are on separate lines with missing semi-colons, they are left on separate lines, but when using template literals the line-break is removed resulting in broken JS.

JS in;

// template literals without semicolons
var foo = `Hello`
foo = `world`

// template literals with semicolons
var foo = `Hello`;
foo = `world`;

// Simple strings without semicolons
var foo = 'Hello'
foo = 'world'

JS out:

var foo=`Hello`foo=`world`var foo=`Hello`;foo=`world`;var foo='Hello'
foo='world';

Minified JS broken with private class identifiers

I report this here once more after posting it on autoptimize.

When a class contains private attributes or methods, the necessary line break or semicolon is not inserted.
As a minimum non-working example, the following class in valid JavaScript syntax does not work:

class TestClass {
    #a = 3
    #b = 5
    #fnc1() {
        do_something()
    }
    #fnc(2) {
        do_anything()
    }
}

It is minified to:

class TestClass{#a=3#b=5#fnc1(){do_something()}#fnc(2){do_anything()}}

which contains several syntax errors: There should be line breaks or semicolons between all the attributes and methods.

Assumption: The hash sign is treated the same way like an operator, and lines beginning with an operator can be appended to the preceding line.

rewrite history

hi @mrclay,

i was wondering, if you be interesting doing git filter branch to trim history to include only files that are jsmin-php related.

it would be probably very good idea to do that before you merge any of the PRs here.

ord() passing only string parameter

Since PHP 7 requires that ord function parameter passing only string type.

The original notice message:

PHP Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated

PHP Deprecation warning: ord(null)

Reproduced in version: 2.4.1 - looks like fix for #10 was incomplete.

When input string ends with single line comment PHP raises deprecation warning:

ord(): Passing null to parameter #1 ($character) of type string is deprecated

at

vendor/mrclay/jsmin-php/src/JSMin/JSMin.php line 390

Reprosteps:

This problem occurs when input string ends with single line comments. Simplest test case:

\JSMin\JSMin::minify('// comment');

Stacktrace:

#1  vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(390): ord(null)
#2  vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(446): JSMin\JSMin->consumeSingleLineComment()
#3  vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(230): JSMin\JSMin->next()
#4  vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(121): JSMin\JSMin->action(3)
#5  vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(86): JSMin\JSMin->min()
#6  JSMin\JSMin::minify("// comment")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.