Refs #482: fixes utils.betterTypeOf() for SlimerJS
In SlimerJS, the webpage object has no type 'qtruntimeobject' written in the string form of the object. But it has a __type property. The function should check this property when the engine is not PhantomJS.
Showing
1 changed file
with
7 additions
and
1 deletions
... | @@ -52,7 +52,13 @@ function betterTypeOf(input) { | ... | @@ -52,7 +52,13 @@ function betterTypeOf(input) { |
52 | return 'null'; | 52 | return 'null'; |
53 | default: | 53 | default: |
54 | try { | 54 | try { |
55 | return Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase(); | 55 | var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase(); |
56 | if (type == 'object' | ||
57 | && phantom.casperEngine != "phantomjs" | ||
58 | && '__type' in input) { | ||
59 | type = input.__type; | ||
60 | } | ||
61 | return type; | ||
56 | } catch (e) { | 62 | } catch (e) { |
57 | return typeof input; | 63 | return typeof input; |
58 | } | 64 | } | ... | ... |
-
Please register or sign in to post a comment