Skip to content

Commit 837a58a

Browse files
committed
Get the view path of a widget on IE
Replace constructor.name with a new function called getName that works on Internet Explorer. This new function is based on this workaround to support Function.name: http://matt.scharley.me/2012/03/09/monkey-patch-name-ie.html Combined with PR Shopify#310, the library works fine on IE. Disclaimer: I do not use Internet Explorer! However, I developed a TV panel using your library, and now we have to support IE...
1 parent 9e8dfe7 commit 837a58a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

javascripts/dashing.coffee

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Dashing.params = Batman.URI.paramsFromQuery(window.location.search.slice(1));
3434
class Dashing.Widget extends Batman.View
3535
constructor: ->
3636
# Set the view path
37-
@constructor::source = Batman.Filters.underscore(@constructor.name)
37+
@constructor::source = Batman.Filters.underscore(@getName())
3838
super
3939

4040
@mixin($(@node).data())
@@ -54,7 +54,15 @@ class Dashing.Widget extends Batman.View
5454

5555
@::on 'ready', ->
5656
Dashing.Widget.fire 'ready'
57-
57+
58+
getName: () =>
59+
if (@constructor.name?)
60+
return @constructor.name
61+
# get constructor name from Function.toString
62+
funcNameRegex = /function ([^\(]{1,})\(/;
63+
results = (funcNameRegex).exec(@constructor.toString())
64+
if (results && results.length > 1) then results[1].trim() else ""
65+
5866
receiveData: (data) =>
5967
@mixin(data)
6068
@onData(data)

0 commit comments

Comments
 (0)