The div that looks different in every browser

Martijn Cuppens tweets the link to this code snippet and a screenshot of how the code renders in different browsers.  Yup.  Each browser produces a different result.  The Twitter thread has more examples.

This is yet another example of how CSS and cross-browser compatibility can drive a web developer insane.

Semantic Versioning : Version 0 is unstable

We’ve been using Semantic Versioning for quite a while at work now.  It’s easy to explain and follow, and it provides valuable context to the numerous releases of the projects and components that we are doing on a daily basis.

Turns out, however, that I missed a small, but important part of the standard.  All releases in major version 0 are considered to be unstable, so even if they introduce backward compatibility breaking changes, there is no need to increment the major version to 1.  Here’s the relevant quote:

Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

If you are relying on the semantic versioning in your projects, make sure to check your dependency management tool, to verify that it handles major version 0 correctly.  Gladly, for us, composer does the job:

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility. For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.

 

What’s the difference between JavaScript and ECMAScript?

Here’s a good explanation on what’s the difference between JavaScript and ECMAScript.  I know I’m not the only one confused.

Chicken or the egg

A confusing bit of history is that JavaScript was created in 1996. It was then submitted to Ecma International in 1997 for standardization, which resulted in ECMAScript. At the same time, because JavaScript conformed to the ECMAScript specification, JavaScript is an example of an ECMAScript implementation.

That leaves us with this fun fact: ECMAScript is based on JavaScript, and JavaScript is based on ECMAScript.

I know.

It sounds exactly like the time-travel trope of people being their own parent — a little wonky, but kind of fun to think about.

JSON5 – JSON for Humans

JSON5 specification looks like a much more useful JSON, especially for those of us who are still more human than machine.  Here are some of the improvements:

  • Objects and arrays can have trailing commas.
  • Strings can be single-quoted.
  • Strings can have line breaks.
  • Numbers can be signed, begin or end with a decimal point, and also in base 16.
  • Inline and block comments are supported.

Here’s an example:

{
    foo: 'bar',
    while: true,

    this: 'is a \
multi-line string',

    // this is an inline comment
    here: 'is another', // inline comment

    /* this is a block comment
       that continues on another line */

    hex: 0xDEADbeef,
    half: .5,
    delta: +10,
    to: Infinity,   // and beyond!

    finally: 'a trailing comma',
    oh: [
        "we shouldn't forget",
        'arrays can have',
        'trailing commas too',
    ],
}

 

RRULE will make you hate calendars

Calendars are not the simplest applications by far.  There are many different features, lots of different implementations, multitude of standards (just a few being RFC 2445, which was obsoleted by RFC 5545, which was updated by RFC 5546, RFC 6868, RFC 7529, RFC 7953, RFC 7986) , and plenty of other complexities.

One area in particular, which is cryptic and annoying is RRULE, or recurrence rule.  You know, those events that don’t just happen once, but repeat once in a while.  Starting with the most basic rules of repeating every day, and going into complete insanity of repeating every other Thursday, starting from next week and until the beginning of next year every other month, RRULEs can drive even the calmest of people completely insane.  Here’s a screenshot to give you an idea.

Here are a couple of tools that we found useful, when implementing and testing this functionality:

  • rrule.js – a JavaScript library for working with RRULEs.  See the demo here.
  • recurr – a PHP library for working with RRULEs.