Permalink
Browse files

renderer: better getprops realization

  • Loading branch information...
1 parent e33e0e3 commit d43aab2c7cd1965cb5035dc0764d39b2a2e02b92 @indutny committed Sep 27, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/spoon/renderer.js
View
@@ -310,7 +310,15 @@ Renderer.prototype.renderGetprop = function renderGetprop(args) {
};
Renderer.prototype.renderGetprops = function renderGetprops(args) {
- return ['call', ['dot', ['name', 'Object'], 'keys'], [ args[0] ]];
+ var type = ['unary-prefix', 'typeof', args[0]],
+ isObject = ['binary',
+ '&&',
+ ['binary', '===', type, ['string', 'object']],
+ ['binary', '!==', args[0], ['name', 'null']]];
+
+ return ['conditional', isObject,
+ ['call', ['dot', ['name', 'Object'], 'keys'], [ args[0] ]],
+ ['object', []]];
};
Renderer.prototype.renderIf = function renderIf(args) {

0 comments on commit d43aab2

Please sign in to comment.