Skip to content

Commit

Permalink
Get the view path of a widget on IE
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
bielfrontera committed Feb 14, 2014
1 parent 9e8dfe7 commit 837a58a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions javascripts/dashing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Dashing.params = Batman.URI.paramsFromQuery(window.location.search.slice(1));
class Dashing.Widget extends Batman.View
constructor: ->
# Set the view path
@constructor::source = Batman.Filters.underscore(@constructor.name)
@constructor::source = Batman.Filters.underscore(@getName())
super

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

@::on 'ready', ->
Dashing.Widget.fire 'ready'


getName: () =>
if (@constructor.name?)
return @constructor.name
# get constructor name from Function.toString
funcNameRegex = /function ([^\(]{1,})\(/;
results = (funcNameRegex).exec(@constructor.toString())
if (results && results.length > 1) then results[1].trim() else ""

receiveData: (data) =>
@mixin(data)
@onData(data)
Expand Down

0 comments on commit 837a58a

Please sign in to comment.