monocle
monocle copied to clipboard
Monocle.Templates cache system can be broken after minification
This issue is related to: https://github.com/jashkenas/coffee-script/issues/2052
In https://github.com/soyjavi/monocle/blob/master/src/monocle.view.coffee, Monocle.Templates
is used to cache the templates:
_loadTemplateFrom: (url) ->
className = @constructor.name
unless Monocle.Templates[className]
loader = if $$? then $$ else $
response = loader.ajax
url: url
async: false
dataType: 'text'
error: -> console.error arguments
response = response.responseText unless $$?
Monocle.Templates[className] = response
@template = Monocle.Templates[className]
The used cache key is @constructor.name
, which can be anything after minification, so it can generate key duplicates.
As a result, two different views could end sharing the same template by error if both views were minified to the same variable name.