pakastin / frzr

Turboboosted 2 KB view library for browser & node.js
https://frzr.js.org
ISC License
265 stars 21 forks source link

isPrimitive method subtle bug #23

Closed jwarnox closed 8 years ago

jwarnox commented 8 years ago

Hi Juha,

Just watched your Minimum Viable View Library talk, fascinating and amazing that in 2k of Javascript you can out perform major frameworks, brilliant stuff keep up the good work!

Playing with the FRZR code and spotted a subtle bug @ https://github.com/pakastin/frzr/blob/master/src/mount.js#L68

Should be:

return typeof check === 'string' || typeof check === 'number' || typeof check === 'boolean';

as

return typeof check === 'string' || check === 'number' || check === 'boolean';

is checking for typeof check === 'string' OR check is a string of 'number' etc

or you can do a lookup say:

var textTypes = { string: 1, number: 1, boolean: 1 }

if (typeof x in textTypes) { ... }

Look forward to more goodness from FRZR

regards, Jamie

pakastin commented 8 years ago

Hi! Great finding! Although I just realized that because of the bug I've been able to use conditionals, like following:

function Login (forgot) {
  this.el = el('form', 
    this.email = el('input, { type: 'email' }),
    forgot && this.pass = el('input', { type: 'password' }),
    this.submit = el('button', { type: 'submit' }, forgot ? 'Send instructions': 'Login')
  });
}

..so I probably drop the support for booleans (which apparently never worked), add for Dates actually (could be useful) and fix for numbers..

I should also add a test case for this. Thanks for contributing and kind words! 👍

Related to #22

pakastin commented 8 years ago

Fixed now, thanks for noticing! 😎