kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
522 stars 60 forks source link

Browser: Object doesn't support property or method 'continueundefined' #73

Closed Adamhtml closed 9 years ago

Adamhtml commented 9 years ago

I realize most folks are probably using vash with nodejs, however the last known version of vash to work in IE 10 was 0.7.12. Version 0.8.0 fails on line 1293, character 3. Subsequent versions similarly fail in Internet Explorer.

Reason: this.node.constructor.name returns 'undefined' in IE

kirbysayshi commented 9 years ago

Wow, I'd forgotten that Function#name was not standard yet every browser but IE supports it. I'll look into alternatives. In the meantime, is it possible for you to precompile your templates in another environment?

Adamhtml commented 9 years ago

Sadly, I require a purely browser-based solution which supports IE. I can wait for an update if you think one might be ready soon, or downgrade to the older version in the interim. Cheers!

kirbysayshi commented 9 years ago

I might have a solution that I can try to attempt tonight:

var nodes = [ProgramNode, TextNode, MarkupNode, ...]
if (ProgramNode.name) return;
nodes.forEach(function(node) {
  var name = /^function\s+?([a-z_0-9]+)\s+?\{/.exec(node.toString();
  node.name = name;
})
Adamhtml commented 9 years ago

With a minor change to the regex to permit uppercase and the argument list parenthesis, it might just work! /^function\s+([A-Za-z0-9_]+)\s*\(/

kirbysayshi commented 9 years ago

@Adamhtml I published a new version v0.8.5... do you mind trying it on IE? I don't have a great IE dev environment setup at the moment.

Adamhtml commented 9 years ago

Confirmed, v0.8.5 does appear to correct the issue in IE. Thanks!

kirbysayshi commented 9 years ago

Awesome, thanks for the great bug report!