evilstreak / markdown-js

A Markdown parser for javascript
7.7k stars 863 forks source link

fix for bug #24 (implicit conversion to a string) #44

Closed rlidwka closed 12 years ago

rlidwka commented 12 years ago

I wonder what javascript engine this module was developed for?

In V8 you can't assign a property to a string. That's why bug #24 appears with Node.js:

var x = new String("test");
x.prop = "hi";
// x == 'test'
// x.prop == 'hi'

x += 'test'
// x == 'testtest'
// x.prop == undefined

x.prop = 'hi'
// x.prop == undefined
// (it's a string now, not an object, it's immutable now)
ashb commented 12 years ago

This was originally developed for a spidermonkey but I'm fairly sure the same rule applies there.