fluentd-ui 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +9 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +4 -1
  5. data/app/assets/javascripts/vue/fluent_log.js +4 -4
  6. data/app/assets/javascripts/vue/in_tail_format.js +43 -49
  7. data/app/assets/javascripts/{alert.js → vue/notification.js} +21 -7
  8. data/app/assets/javascripts/vue/settings.js +121 -0
  9. data/app/assets/javascripts/vue/treeview.js +3 -3
  10. data/app/assets/stylesheets/common.css.scss +7 -1
  11. data/app/controllers/api/settings_controller.rb +55 -0
  12. data/app/controllers/api_controller.rb +6 -2
  13. data/app/controllers/concerns/setting_concern.rb +2 -2
  14. data/app/controllers/fluentd/settings_controller.rb +17 -2
  15. data/app/models/fluentd/setting/config.rb +39 -0
  16. data/app/views/api/settings/_element.json.jbuilder +6 -0
  17. data/app/views/api/settings/index.json.jbuilder +3 -0
  18. data/app/views/api/settings/show.json.jbuilder +1 -0
  19. data/app/views/fluentd/settings/edit.html.haml +3 -0
  20. data/app/views/fluentd/settings/source_and_output.html.haml +19 -2
  21. data/app/views/layouts/application.html.erb +1 -30
  22. data/app/views/shared/vue/_in_tail_format.html.erb +11 -36
  23. data/app/views/shared/vue/_notification.html.erb +31 -0
  24. data/app/views/shared/vue/_setting.html.erb +23 -0
  25. data/app/views/shared/vue/_treeview.html.erb +2 -2
  26. data/bower.json +1 -1
  27. data/config/application.rb +1 -0
  28. data/config/locales/translation_en.yml +11 -7
  29. data/config/locales/translation_ja.yml +4 -0
  30. data/config/routes.rb +2 -0
  31. data/lib/fluentd-ui/version.rb +1 -1
  32. data/spec/features/fluentd/setting/source_and_output_spec.rb +157 -0
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/support/javascript_macro.rb +21 -0
  35. data/vendor/assets/javascripts/bower/vue/.bower.json +7 -7
  36. data/vendor/assets/javascripts/bower/vue/LICENSE +1 -1
  37. data/vendor/assets/javascripts/bower/vue/dist/vue.js +7822 -4768
  38. data/vendor/assets/javascripts/bower/vue/dist/vue.min.js +7 -7
  39. data/vendor/assets/javascripts/bower/vue/src/api/child.js +53 -0
  40. data/vendor/assets/javascripts/bower/vue/src/api/data.js +161 -0
  41. data/vendor/assets/javascripts/bower/vue/src/api/dom.js +211 -0
  42. data/vendor/assets/javascripts/bower/vue/src/api/events.js +176 -0
  43. data/vendor/assets/javascripts/bower/vue/src/api/global.js +146 -0
  44. data/vendor/assets/javascripts/bower/vue/src/api/lifecycle.js +144 -0
  45. data/vendor/assets/javascripts/bower/vue/src/batcher.js +52 -32
  46. data/vendor/assets/javascripts/bower/vue/src/cache.js +112 -0
  47. data/vendor/assets/javascripts/bower/vue/src/compiler/compile.js +549 -0
  48. data/vendor/assets/javascripts/bower/vue/src/compiler/transclude.js +163 -0
  49. data/vendor/assets/javascripts/bower/vue/src/config.js +74 -14
  50. data/vendor/assets/javascripts/bower/vue/src/directive.js +179 -219
  51. data/vendor/assets/javascripts/bower/vue/src/directives/attr.js +32 -0
  52. data/vendor/assets/javascripts/bower/vue/src/directives/class.js +18 -0
  53. data/vendor/assets/javascripts/bower/vue/src/directives/cloak.js +12 -0
  54. data/vendor/assets/javascripts/bower/vue/src/directives/component.js +214 -0
  55. data/vendor/assets/javascripts/bower/vue/src/directives/el.js +13 -0
  56. data/vendor/assets/javascripts/bower/vue/src/directives/html.js +30 -34
  57. data/vendor/assets/javascripts/bower/vue/src/directives/if.js +77 -46
  58. data/vendor/assets/javascripts/bower/vue/src/directives/index.js +22 -129
  59. data/vendor/assets/javascripts/bower/vue/src/directives/model/checkbox.js +25 -0
  60. data/vendor/assets/javascripts/bower/vue/src/directives/model/default.js +123 -0
  61. data/vendor/assets/javascripts/bower/vue/src/directives/model/index.js +56 -0
  62. data/vendor/assets/javascripts/bower/vue/src/directives/model/radio.js +26 -0
  63. data/vendor/assets/javascripts/bower/vue/src/directives/model/select.js +166 -0
  64. data/vendor/assets/javascripts/bower/vue/src/directives/on.js +51 -50
  65. data/vendor/assets/javascripts/bower/vue/src/directives/partial.js +36 -42
  66. data/vendor/assets/javascripts/bower/vue/src/directives/ref.js +24 -0
  67. data/vendor/assets/javascripts/bower/vue/src/directives/repeat.js +477 -226
  68. data/vendor/assets/javascripts/bower/vue/src/directives/show.js +8 -0
  69. data/vendor/assets/javascripts/bower/vue/src/directives/style.js +49 -37
  70. data/vendor/assets/javascripts/bower/vue/src/directives/text.js +15 -0
  71. data/vendor/assets/javascripts/bower/vue/src/directives/transition.js +12 -0
  72. data/vendor/assets/javascripts/bower/vue/src/directives/with.js +38 -41
  73. data/vendor/assets/javascripts/bower/vue/src/filters/array-filters.js +87 -0
  74. data/vendor/assets/javascripts/bower/vue/src/filters/index.js +135 -0
  75. data/vendor/assets/javascripts/bower/vue/src/instance/compile.js +71 -0
  76. data/vendor/assets/javascripts/bower/vue/src/instance/events.js +122 -0
  77. data/vendor/assets/javascripts/bower/vue/src/instance/init.js +76 -0
  78. data/vendor/assets/javascripts/bower/vue/src/instance/scope.js +217 -0
  79. data/vendor/assets/javascripts/bower/vue/src/observer/array.js +90 -0
  80. data/vendor/assets/javascripts/bower/vue/src/observer/dep.js +50 -0
  81. data/vendor/assets/javascripts/bower/vue/src/observer/index.js +235 -0
  82. data/vendor/assets/javascripts/bower/vue/src/observer/object.js +75 -0
  83. data/vendor/assets/javascripts/bower/vue/src/parsers/directive.js +159 -0
  84. data/vendor/assets/javascripts/bower/vue/src/parsers/expression.js +226 -0
  85. data/vendor/assets/javascripts/bower/vue/src/parsers/path.js +300 -0
  86. data/vendor/assets/javascripts/bower/vue/src/parsers/template.js +246 -0
  87. data/vendor/assets/javascripts/bower/vue/src/parsers/text.js +178 -0
  88. data/vendor/assets/javascripts/bower/vue/src/transition/css.js +189 -0
  89. data/vendor/assets/javascripts/bower/vue/src/transition/index.js +151 -0
  90. data/vendor/assets/javascripts/bower/vue/src/transition/js.js +43 -0
  91. data/vendor/assets/javascripts/bower/vue/src/util/debug.js +50 -0
  92. data/vendor/assets/javascripts/bower/vue/src/util/dom.js +176 -0
  93. data/vendor/assets/javascripts/bower/vue/src/util/env.js +74 -0
  94. data/vendor/assets/javascripts/bower/vue/src/util/filter.js +72 -0
  95. data/vendor/assets/javascripts/bower/vue/src/util/index.js +8 -0
  96. data/vendor/assets/javascripts/bower/vue/src/util/lang.js +175 -0
  97. data/vendor/assets/javascripts/bower/vue/src/util/merge-option.js +258 -0
  98. data/vendor/assets/javascripts/bower/vue/src/vue.js +84 -0
  99. data/vendor/assets/javascripts/bower/vue/src/watcher.js +240 -0
  100. metadata +65 -20
  101. data/app/assets/javascripts/setting_format.js +0 -15
  102. data/vendor/assets/javascripts/bower/vue/src/binding.js +0 -103
  103. data/vendor/assets/javascripts/bower/vue/src/compiler.js +0 -1037
  104. data/vendor/assets/javascripts/bower/vue/src/deps-parser.js +0 -65
  105. data/vendor/assets/javascripts/bower/vue/src/directives/model.js +0 -174
  106. data/vendor/assets/javascripts/bower/vue/src/directives/view.js +0 -56
  107. data/vendor/assets/javascripts/bower/vue/src/emitter.js +0 -97
  108. data/vendor/assets/javascripts/bower/vue/src/exp-parser.js +0 -190
  109. data/vendor/assets/javascripts/bower/vue/src/filters.js +0 -191
  110. data/vendor/assets/javascripts/bower/vue/src/fragment.js +0 -67
  111. data/vendor/assets/javascripts/bower/vue/src/main.js +0 -188
  112. data/vendor/assets/javascripts/bower/vue/src/observer.js +0 -446
  113. data/vendor/assets/javascripts/bower/vue/src/template-parser.js +0 -46
  114. data/vendor/assets/javascripts/bower/vue/src/text-parser.js +0 -96
  115. data/vendor/assets/javascripts/bower/vue/src/transition.js +0 -228
  116. data/vendor/assets/javascripts/bower/vue/src/utils.js +0 -326
  117. data/vendor/assets/javascripts/bower/vue/src/viewmodel.js +0 -190
@@ -0,0 +1,549 @@
1
+ var _ = require('../util')
2
+ var config = require('../config')
3
+ var textParser = require('../parsers/text')
4
+ var dirParser = require('../parsers/directive')
5
+ var templateParser = require('../parsers/template')
6
+
7
+ /**
8
+ * Compile a template and return a reusable composite link
9
+ * function, which recursively contains more link functions
10
+ * inside. This top level compile function should only be
11
+ * called on instance root nodes.
12
+ *
13
+ * When the `asParent` flag is true, this means we are doing
14
+ * a partial compile for a component's parent scope markup
15
+ * (See #502). This could **only** be triggered during
16
+ * compilation of `v-component`, and we need to skip v-with,
17
+ * v-ref & v-component in this situation.
18
+ *
19
+ * @param {Element|DocumentFragment} el
20
+ * @param {Object} options
21
+ * @param {Boolean} partial
22
+ * @param {Boolean} asParent
23
+ * @return {Function}
24
+ */
25
+
26
+ module.exports = function compile (el, options, partial, asParent) {
27
+ var params = !partial && options.paramAttributes
28
+ var paramsLinkFn = params
29
+ ? compileParamAttributes(el, params, options)
30
+ : null
31
+ var nodeLinkFn = el instanceof DocumentFragment
32
+ ? null
33
+ : compileNode(el, options, asParent)
34
+ var childLinkFn =
35
+ !(nodeLinkFn && nodeLinkFn.terminal) &&
36
+ el.tagName !== 'SCRIPT' &&
37
+ el.hasChildNodes()
38
+ ? compileNodeList(el.childNodes, options)
39
+ : null
40
+
41
+ /**
42
+ * A linker function to be called on a already compiled
43
+ * piece of DOM, which instantiates all directive
44
+ * instances.
45
+ *
46
+ * @param {Vue} vm
47
+ * @param {Element|DocumentFragment} el
48
+ * @return {Function|undefined}
49
+ */
50
+
51
+ return function link (vm, el) {
52
+ var originalDirCount = vm._directives.length
53
+ if (paramsLinkFn) paramsLinkFn(vm, el)
54
+ if (nodeLinkFn) nodeLinkFn(vm, el)
55
+ if (childLinkFn) childLinkFn(vm, el.childNodes)
56
+
57
+ /**
58
+ * If this is a partial compile, the linker function
59
+ * returns an unlink function that tearsdown all
60
+ * directives instances generated during the partial
61
+ * linking.
62
+ */
63
+
64
+ if (partial) {
65
+ var dirs = vm._directives.slice(originalDirCount)
66
+ return function unlink () {
67
+ var i = dirs.length
68
+ while (i--) {
69
+ dirs[i]._teardown()
70
+ }
71
+ i = vm._directives.indexOf(dirs[0])
72
+ vm._directives.splice(i, dirs.length)
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Compile a node and return a nodeLinkFn based on the
80
+ * node type.
81
+ *
82
+ * @param {Node} node
83
+ * @param {Object} options
84
+ * @param {Boolean} asParent
85
+ * @return {Function|undefined}
86
+ */
87
+
88
+ function compileNode (node, options, asParent) {
89
+ var type = node.nodeType
90
+ if (type === 1 && node.tagName !== 'SCRIPT') {
91
+ return compileElement(node, options, asParent)
92
+ } else if (type === 3 && config.interpolate) {
93
+ return compileTextNode(node, options)
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Compile an element and return a nodeLinkFn.
99
+ *
100
+ * @param {Element} el
101
+ * @param {Object} options
102
+ * @param {Boolean} asParent
103
+ * @return {Function|null}
104
+ */
105
+
106
+ function compileElement (el, options, asParent) {
107
+ var linkFn, tag, component
108
+ // check custom element component, but only on non-root
109
+ if (!asParent && !el.__vue__) {
110
+ tag = el.tagName.toLowerCase()
111
+ component =
112
+ tag.indexOf('-') > 0 &&
113
+ options.components[tag]
114
+ if (component) {
115
+ el.setAttribute(config.prefix + 'component', tag)
116
+ }
117
+ }
118
+ if (component || el.hasAttributes()) {
119
+ // check terminal direcitves
120
+ if (!asParent) {
121
+ linkFn = checkTerminalDirectives(el, options)
122
+ }
123
+ // if not terminal, build normal link function
124
+ if (!linkFn) {
125
+ var dirs = collectDirectives(el, options, asParent)
126
+ linkFn = dirs.length
127
+ ? makeDirectivesLinkFn(dirs)
128
+ : null
129
+ }
130
+ }
131
+ // if the element is a textarea, we need to interpolate
132
+ // its content on initial render.
133
+ if (el.tagName === 'TEXTAREA') {
134
+ var realLinkFn = linkFn
135
+ linkFn = function (vm, el) {
136
+ el.value = vm.$interpolate(el.value)
137
+ if (realLinkFn) realLinkFn(vm, el)
138
+ }
139
+ linkFn.terminal = true
140
+ }
141
+ return linkFn
142
+ }
143
+
144
+ /**
145
+ * Build a multi-directive link function.
146
+ *
147
+ * @param {Array} directives
148
+ * @return {Function} directivesLinkFn
149
+ */
150
+
151
+ function makeDirectivesLinkFn (directives) {
152
+ return function directivesLinkFn (vm, el) {
153
+ // reverse apply because it's sorted low to high
154
+ var i = directives.length
155
+ var dir, j, k
156
+ while (i--) {
157
+ dir = directives[i]
158
+ if (dir._link) {
159
+ // custom link fn
160
+ dir._link(vm, el)
161
+ } else {
162
+ k = dir.descriptors.length
163
+ for (j = 0; j < k; j++) {
164
+ vm._bindDir(dir.name, el,
165
+ dir.descriptors[j], dir.def)
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Compile a textNode and return a nodeLinkFn.
174
+ *
175
+ * @param {TextNode} node
176
+ * @param {Object} options
177
+ * @return {Function|null} textNodeLinkFn
178
+ */
179
+
180
+ function compileTextNode (node, options) {
181
+ var tokens = textParser.parse(node.nodeValue)
182
+ if (!tokens) {
183
+ return null
184
+ }
185
+ var frag = document.createDocumentFragment()
186
+ var el, token
187
+ for (var i = 0, l = tokens.length; i < l; i++) {
188
+ token = tokens[i]
189
+ el = token.tag
190
+ ? processTextToken(token, options)
191
+ : document.createTextNode(token.value)
192
+ frag.appendChild(el)
193
+ }
194
+ return makeTextNodeLinkFn(tokens, frag, options)
195
+ }
196
+
197
+ /**
198
+ * Process a single text token.
199
+ *
200
+ * @param {Object} token
201
+ * @param {Object} options
202
+ * @return {Node}
203
+ */
204
+
205
+ function processTextToken (token, options) {
206
+ var el
207
+ if (token.oneTime) {
208
+ el = document.createTextNode(token.value)
209
+ } else {
210
+ if (token.html) {
211
+ el = document.createComment('v-html')
212
+ setTokenType('html')
213
+ } else if (token.partial) {
214
+ el = document.createComment('v-partial')
215
+ setTokenType('partial')
216
+ } else {
217
+ // IE will clean up empty textNodes during
218
+ // frag.cloneNode(true), so we have to give it
219
+ // something here...
220
+ el = document.createTextNode(' ')
221
+ setTokenType('text')
222
+ }
223
+ }
224
+ function setTokenType (type) {
225
+ token.type = type
226
+ token.def = options.directives[type]
227
+ token.descriptor = dirParser.parse(token.value)[0]
228
+ }
229
+ return el
230
+ }
231
+
232
+ /**
233
+ * Build a function that processes a textNode.
234
+ *
235
+ * @param {Array<Object>} tokens
236
+ * @param {DocumentFragment} frag
237
+ */
238
+
239
+ function makeTextNodeLinkFn (tokens, frag) {
240
+ return function textNodeLinkFn (vm, el) {
241
+ var fragClone = frag.cloneNode(true)
242
+ var childNodes = _.toArray(fragClone.childNodes)
243
+ var token, value, node
244
+ for (var i = 0, l = tokens.length; i < l; i++) {
245
+ token = tokens[i]
246
+ value = token.value
247
+ if (token.tag) {
248
+ node = childNodes[i]
249
+ if (token.oneTime) {
250
+ value = vm.$eval(value)
251
+ if (token.html) {
252
+ _.replace(node, templateParser.parse(value, true))
253
+ } else {
254
+ node.nodeValue = value
255
+ }
256
+ } else {
257
+ vm._bindDir(token.type, node,
258
+ token.descriptor, token.def)
259
+ }
260
+ }
261
+ }
262
+ _.replace(el, fragClone)
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Compile a node list and return a childLinkFn.
268
+ *
269
+ * @param {NodeList} nodeList
270
+ * @param {Object} options
271
+ * @return {Function|undefined}
272
+ */
273
+
274
+ function compileNodeList (nodeList, options) {
275
+ var linkFns = []
276
+ var nodeLinkFn, childLinkFn, node
277
+ for (var i = 0, l = nodeList.length; i < l; i++) {
278
+ node = nodeList[i]
279
+ nodeLinkFn = compileNode(node, options)
280
+ childLinkFn =
281
+ !(nodeLinkFn && nodeLinkFn.terminal) &&
282
+ node.tagName !== 'SCRIPT' &&
283
+ node.hasChildNodes()
284
+ ? compileNodeList(node.childNodes, options)
285
+ : null
286
+ linkFns.push(nodeLinkFn, childLinkFn)
287
+ }
288
+ return linkFns.length
289
+ ? makeChildLinkFn(linkFns)
290
+ : null
291
+ }
292
+
293
+ /**
294
+ * Make a child link function for a node's childNodes.
295
+ *
296
+ * @param {Array<Function>} linkFns
297
+ * @return {Function} childLinkFn
298
+ */
299
+
300
+ function makeChildLinkFn (linkFns) {
301
+ return function childLinkFn (vm, nodes) {
302
+ // stablize nodes
303
+ nodes = _.toArray(nodes)
304
+ var node, nodeLinkFn, childrenLinkFn
305
+ for (var i = 0, n = 0, l = linkFns.length; i < l; n++) {
306
+ node = nodes[n]
307
+ nodeLinkFn = linkFns[i++]
308
+ childrenLinkFn = linkFns[i++]
309
+ if (nodeLinkFn) {
310
+ nodeLinkFn(vm, node)
311
+ }
312
+ if (childrenLinkFn) {
313
+ childrenLinkFn(vm, node.childNodes)
314
+ }
315
+ }
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Compile param attributes on a root element and return
321
+ * a paramAttributes link function.
322
+ *
323
+ * @param {Element} el
324
+ * @param {Array} attrs
325
+ * @param {Object} options
326
+ * @return {Function} paramsLinkFn
327
+ */
328
+
329
+ function compileParamAttributes (el, attrs, options) {
330
+ var params = []
331
+ var i = attrs.length
332
+ var name, value, param
333
+ while (i--) {
334
+ name = attrs[i]
335
+ value = el.getAttribute(name)
336
+ if (value !== null) {
337
+ param = {
338
+ name: name,
339
+ value: value
340
+ }
341
+ var tokens = textParser.parse(value)
342
+ if (tokens) {
343
+ el.removeAttribute(name)
344
+ if (tokens.length > 1) {
345
+ _.warn(
346
+ 'Invalid param attribute binding: "' +
347
+ name + '="' + value + '"' +
348
+ '\nDon\'t mix binding tags with plain text ' +
349
+ 'in param attribute bindings.'
350
+ )
351
+ continue
352
+ } else {
353
+ param.dynamic = true
354
+ param.value = tokens[0].value
355
+ }
356
+ }
357
+ params.push(param)
358
+ }
359
+ }
360
+ return makeParamsLinkFn(params, options)
361
+ }
362
+
363
+ /**
364
+ * Build a function that applies param attributes to a vm.
365
+ *
366
+ * @param {Array} params
367
+ * @param {Object} options
368
+ * @return {Function} paramsLinkFn
369
+ */
370
+
371
+ var dataAttrRE = /^data-/
372
+
373
+ function makeParamsLinkFn (params, options) {
374
+ var def = options.directives['with']
375
+ return function paramsLinkFn (vm, el) {
376
+ var i = params.length
377
+ var param, path
378
+ while (i--) {
379
+ param = params[i]
380
+ // params could contain dashes, which will be
381
+ // interpreted as minus calculations by the parser
382
+ // so we need to wrap the path here
383
+ path = _.camelize(param.name.replace(dataAttrRE, ''))
384
+ if (param.dynamic) {
385
+ // dynamic param attribtues are bound as v-with.
386
+ // we can directly duck the descriptor here beacuse
387
+ // param attributes cannot use expressions or
388
+ // filters.
389
+ vm._bindDir('with', el, {
390
+ arg: path,
391
+ expression: param.value
392
+ }, def)
393
+ } else {
394
+ // just set once
395
+ vm.$set(path, param.value)
396
+ }
397
+ }
398
+ }
399
+ }
400
+
401
+ /**
402
+ * Check an element for terminal directives in fixed order.
403
+ * If it finds one, return a terminal link function.
404
+ *
405
+ * @param {Element} el
406
+ * @param {Object} options
407
+ * @return {Function} terminalLinkFn
408
+ */
409
+
410
+ var terminalDirectives = [
411
+ 'repeat',
412
+ 'if',
413
+ 'component'
414
+ ]
415
+
416
+ function skip () {}
417
+ skip.terminal = true
418
+
419
+ function checkTerminalDirectives (el, options) {
420
+ if (_.attr(el, 'pre') !== null) {
421
+ return skip
422
+ }
423
+ var value, dirName
424
+ /* jshint boss: true */
425
+ for (var i = 0; i < 3; i++) {
426
+ dirName = terminalDirectives[i]
427
+ if (value = _.attr(el, dirName)) {
428
+ return makeTeriminalLinkFn(el, dirName, value, options)
429
+ }
430
+ }
431
+ }
432
+
433
+ /**
434
+ * Build a link function for a terminal directive.
435
+ *
436
+ * @param {Element} el
437
+ * @param {String} dirName
438
+ * @param {String} value
439
+ * @param {Object} options
440
+ * @return {Function} terminalLinkFn
441
+ */
442
+
443
+ function makeTeriminalLinkFn (el, dirName, value, options) {
444
+ var descriptor = dirParser.parse(value)[0]
445
+ var def = options.directives[dirName]
446
+ var terminalLinkFn = function (vm, el) {
447
+ vm._bindDir(dirName, el, descriptor, def)
448
+ }
449
+ terminalLinkFn.terminal = true
450
+ return terminalLinkFn
451
+ }
452
+
453
+ /**
454
+ * Collect the directives on an element.
455
+ *
456
+ * @param {Element} el
457
+ * @param {Object} options
458
+ * @param {Boolean} asParent
459
+ * @return {Array}
460
+ */
461
+
462
+ function collectDirectives (el, options, asParent) {
463
+ var attrs = _.toArray(el.attributes)
464
+ var i = attrs.length
465
+ var dirs = []
466
+ var attr, attrName, dir, dirName, dirDef
467
+ while (i--) {
468
+ attr = attrs[i]
469
+ attrName = attr.name
470
+ if (attrName.indexOf(config.prefix) === 0) {
471
+ dirName = attrName.slice(config.prefix.length)
472
+ if (asParent &&
473
+ (dirName === 'with' ||
474
+ dirName === 'ref' ||
475
+ dirName === 'component')) {
476
+ continue
477
+ }
478
+ dirDef = options.directives[dirName]
479
+ _.assertAsset(dirDef, 'directive', dirName)
480
+ if (dirDef) {
481
+ dirs.push({
482
+ name: dirName,
483
+ descriptors: dirParser.parse(attr.value),
484
+ def: dirDef
485
+ })
486
+ }
487
+ } else if (config.interpolate) {
488
+ dir = collectAttrDirective(el, attrName, attr.value,
489
+ options)
490
+ if (dir) {
491
+ dirs.push(dir)
492
+ }
493
+ }
494
+ }
495
+ // sort by priority, LOW to HIGH
496
+ dirs.sort(directiveComparator)
497
+ return dirs
498
+ }
499
+
500
+ /**
501
+ * Check an attribute for potential dynamic bindings,
502
+ * and return a directive object.
503
+ *
504
+ * @param {Element} el
505
+ * @param {String} name
506
+ * @param {String} value
507
+ * @param {Object} options
508
+ * @return {Object}
509
+ */
510
+
511
+ function collectAttrDirective (el, name, value, options) {
512
+ var tokens = textParser.parse(value)
513
+ if (tokens) {
514
+ var def = options.directives.attr
515
+ var i = tokens.length
516
+ var allOneTime = true
517
+ while (i--) {
518
+ var token = tokens[i]
519
+ if (token.tag && !token.oneTime) {
520
+ allOneTime = false
521
+ }
522
+ }
523
+ return {
524
+ def: def,
525
+ _link: allOneTime
526
+ ? function (vm, el) {
527
+ el.setAttribute(name, vm.$interpolate(value))
528
+ }
529
+ : function (vm, el) {
530
+ var value = textParser.tokensToExp(tokens, vm)
531
+ var desc = dirParser.parse(name + ':' + value)[0]
532
+ vm._bindDir('attr', el, desc, def)
533
+ }
534
+ }
535
+ }
536
+ }
537
+
538
+ /**
539
+ * Directive priority sort comparator
540
+ *
541
+ * @param {Object} a
542
+ * @param {Object} b
543
+ */
544
+
545
+ function directiveComparator (a, b) {
546
+ a = a.def.priority || 0
547
+ b = b.def.priority || 0
548
+ return a > b ? 1 : -1
549
+ }