jsx / JSX

JSX - a faster, safer, easier JavaScript
http://jsx.github.io/
MIT License
1.46k stars 102 forks source link

Can't downcast with template(array, map) #277

Closed shibukawa closed 11 years ago

shibukawa commented 11 years ago

when Element extends Node, following code is invalid:

var elements = nodes as Element[];

but following code is valid:

var element = node as Element;
gfx commented 11 years ago

I think this is a specification. Consider the following code:

var elements = nodes as Element[];

which really means:

var elements = new Element[];
nodes.forEach((node, i) -> {
  elements[i] = nodes[i] as Element;
});

Taking O(n) calculation. Is it what you really want?

shibukawa commented 11 years ago

OK I understand. It takes much cost, current spec is better.

mazandaran commented 11 years ago

maplay