|
|
@@ -3,6 +3,7 @@ var config = require('./config'),
|
|
|
win = window,
|
|
|
console = win.console,
|
|
|
timeout = win.setTimeout,
|
|
|
+ THIS_RE = /[^\w]this\./,
|
|
|
hasClassList = 'classList' in document.documentElement,
|
|
|
ViewModel // late def
|
|
|
|
|
|
@@ -164,6 +165,16 @@ var utils = module.exports = {
|
|
|
: null
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * Check if a filter function contains references to `this`
|
|
|
+ * If yes, mark it as a computed filter.
|
|
|
+ */
|
|
|
+ checkFilter: function (filter) {
|
|
|
+ if (THIS_RE.test(filter.toString())) {
|
|
|
+ filter.computed = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* convert certain option values to the desired format.
|
|
|
*/
|
|
|
@@ -171,6 +182,7 @@ var utils = module.exports = {
|
|
|
var components = options.components,
|
|
|
partials = options.partials,
|
|
|
template = options.template,
|
|
|
+ filters = options.filters,
|
|
|
key
|
|
|
if (components) {
|
|
|
for (key in components) {
|
|
|
@@ -182,6 +194,11 @@ var utils = module.exports = {
|
|
|
partials[key] = utils.toFragment(partials[key])
|
|
|
}
|
|
|
}
|
|
|
+ if (filters) {
|
|
|
+ for (key in filters) {
|
|
|
+ utils.checkFilter(filters[key])
|
|
|
+ }
|
|
|
+ }
|
|
|
if (template) {
|
|
|
options.template = utils.toFragment(template)
|
|
|
}
|