lhorie/mithril.js — pull request #374 by kayellpeee (2014-12-04 05:53:02+00:00)
Title: specify tag name and css selector

Currently you can create DOM elements with specified class or id doing something like this:
m(“div.foo”, “bar") // className === ‘foo’

However, trying to add a space would give an error:
m(“div .foo”, “bar”) // error!
Uncaught InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('div ') is not a valid name.

Updated parser to ignore any whitespace inside the first argument, so it now correctly creates “div” or other DOM elements, with correct class or id.

Not sure if it’s desired functionality, but seeing as how m(“div.foo”) already works, I figured this makes that usage easier to read

![screen shot 2014-12-03 at 9 45 44 pm](https://cloud.githubusercontent.com/assets/6556190/5294234/9ae3470c-7b36-11e4-9ee0-4aea024f2002.png)
![screen shot 2014-12-03 at 9 45 39 pm](https://cloud.githubusercontent.com/assets/6556190/5294236/a20cfa1e-7b36-11e4-8f96-c5fb686c6769.png)

(mithril.min.js)
![screen shot 2014-12-03 at 9 45 13 pm](https://cloud.githubusercontent.com/assets/6556190/5294239/a71d9612-7b36-11e4-9521-62a6b5e7c668.png)