vuejs-rails 0.10.3 → 0.10.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22240b724f3d5116a4034ee4eee59501bdcde4d9
4
- data.tar.gz: b7a6c1d8dfd8a317f4967abcd017d0e76419fc8c
3
+ metadata.gz: 0c8cb6ed9f857d7eccdf3659c6c70d48cddc61a2
4
+ data.tar.gz: dfcd6db0450d372dbb3de553210f7728113a78e5
5
5
  SHA512:
6
- metadata.gz: e83e10320bc80db2f3dcd69282010e532223b4d983b49f9ba2dc9cca0972a23aec1448bec4319234391d3000ee92906c955410c536efd0c2d1d34d1cfd29b805
7
- data.tar.gz: 17cbe884420e763ed0767534b69f77bce701b44243e5963d52394f1af66ae0c0f8eacdbd72f434d5126d471773dead2eac7f45e7a10dcdbf388492f9ac65e426
6
+ metadata.gz: bdf53d882901013543396ff0403bd0278d0bd5b06984ff365ddba78bea80d90e1b70eb78571fc54dc12331560d0c13159b24f7daa5daf0c2a637120818a0dd0e
7
+ data.tar.gz: a436615ce3c78a45cf70dfefb25dcbc51b490c5f4ec79e3bc054479354bf83cbf0ef418a599d57b1951b34432029bb335017ef1d4e31c99fd7ec3777aee8c2c6
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013 Adam Butler
3
+ Copyright (c) 2013 - 2014 Adam Butler
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  module Vue
2
2
  module Rails
3
- VERSION = "0.10.3"
3
+ VERSION = "0.10.4"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*
2
- Vue.js v0.10.3
2
+ Vue.js v0.10.4
3
3
  (c) 2014 Evan You
4
4
  License: MIT
5
5
  */
@@ -317,7 +317,10 @@ function extend (options) {
317
317
  }
318
318
 
319
319
  // inherit options
320
- options = inheritOptions(options, ParentVM.options, true)
320
+ // but only when the super class is not the native Vue.
321
+ if (ParentVM !== ViewModel) {
322
+ options = inheritOptions(options, ParentVM.options, true)
323
+ }
321
324
  utils.processOptions(options)
322
325
 
323
326
  var ExtendedVM = function (opts, asParent) {
@@ -394,20 +397,22 @@ function inheritOptions (child, parent, topLevel) {
394
397
  module.exports = ViewModel
395
398
  });
396
399
  require.register("vue/src/emitter.js", function(exports, require, module){
400
+ var slice = [].slice
401
+
397
402
  function Emitter (ctx) {
398
403
  this._ctx = ctx || this
399
404
  }
400
405
 
401
406
  var EmitterProto = Emitter.prototype
402
407
 
403
- EmitterProto.on = function(event, fn){
408
+ EmitterProto.on = function (event, fn) {
404
409
  this._cbs = this._cbs || {}
405
410
  ;(this._cbs[event] = this._cbs[event] || [])
406
411
  .push(fn)
407
412
  return this
408
413
  }
409
414
 
410
- EmitterProto.once = function(event, fn){
415
+ EmitterProto.once = function (event, fn) {
411
416
  var self = this
412
417
  this._cbs = this._cbs || {}
413
418
 
@@ -421,7 +426,7 @@ EmitterProto.once = function(event, fn){
421
426
  return this
422
427
  }
423
428
 
424
- EmitterProto.off = function(event, fn){
429
+ EmitterProto.off = function (event, fn) {
425
430
  this._cbs = this._cbs || {}
426
431
 
427
432
  // all
@@ -452,7 +457,11 @@ EmitterProto.off = function(event, fn){
452
457
  return this
453
458
  }
454
459
 
455
- EmitterProto.emit = function(event, a, b, c){
460
+ /**
461
+ * The internal, faster emit with fixed amount of arguments
462
+ * using Function.call
463
+ */
464
+ EmitterProto.emit = function (event, a, b, c) {
456
465
  this._cbs = this._cbs || {}
457
466
  var callbacks = this._cbs[event]
458
467
 
@@ -466,6 +475,24 @@ EmitterProto.emit = function(event, a, b, c){
466
475
  return this
467
476
  }
468
477
 
478
+ /**
479
+ * The external emit using Function.apply
480
+ */
481
+ EmitterProto.applyEmit = function (event) {
482
+ this._cbs = this._cbs || {}
483
+ var callbacks = this._cbs[event], args
484
+
485
+ if (callbacks) {
486
+ callbacks = callbacks.slice(0)
487
+ args = slice.call(arguments, 1)
488
+ for (var i = 0, len = callbacks.length; i < len; i++) {
489
+ callbacks[i].apply(this._ctx, args)
490
+ }
491
+ }
492
+
493
+ return this
494
+ }
495
+
469
496
  module.exports = Emitter
470
497
  });
471
498
  require.register("vue/src/config.js", function(exports, require, module){
@@ -494,15 +521,24 @@ var config = require('./config'),
494
521
  toString = ({}).toString,
495
522
  win = window,
496
523
  console = win.console,
497
- timeout = win.setTimeout,
498
524
  def = Object.defineProperty,
499
- THIS_RE = /[^\w]this[^\w]/,
500
525
  OBJECT = 'object',
526
+ THIS_RE = /[^\w]this[^\w]/,
501
527
  hasClassList = 'classList' in document.documentElement,
502
528
  ViewModel // late def
503
529
 
530
+ var defer =
531
+ win.requestAnimationFrame ||
532
+ win.webkitRequestAnimationFrame ||
533
+ win.setTimeout
534
+
504
535
  var utils = module.exports = {
505
536
 
537
+ /**
538
+ * Convert a string template to a dom fragment
539
+ */
540
+ toFragment: require('./fragment'),
541
+
506
542
  /**
507
543
  * get a value from an object keypath
508
544
  */
@@ -656,36 +692,6 @@ var utils = module.exports = {
656
692
  return res
657
693
  },
658
694
 
659
- /**
660
- * Convert a string template to a dom fragment
661
- */
662
- toFragment: function (template) {
663
- if (typeof template !== 'string') {
664
- return template
665
- }
666
- if (template.charAt(0) === '#') {
667
- var templateNode = document.getElementById(template.slice(1))
668
- if (!templateNode) return
669
- // if its a template tag and the browser supports it,
670
- // its content is already a document fragment!
671
- if (templateNode.tagName === 'TEMPLATE' && templateNode.content) {
672
- return templateNode.content
673
- }
674
- template = templateNode.innerHTML
675
- }
676
- var node = document.createElement('div'),
677
- frag = document.createDocumentFragment(),
678
- child
679
- node.innerHTML = template.trim()
680
- /* jshint boss: true */
681
- while (child = node.firstChild) {
682
- if (node.nodeType === 1) {
683
- frag.appendChild(child)
684
- }
685
- }
686
- return frag
687
- },
688
-
689
695
  /**
690
696
  * Convert the object to a ViewModel constructor
691
697
  * if it is not already one
@@ -742,7 +748,7 @@ var utils = module.exports = {
742
748
  * used to defer batch updates
743
749
  */
744
750
  nextTick: function (cb) {
745
- timeout(cb, 0)
751
+ defer(cb, 0)
746
752
  },
747
753
 
748
754
  /**
@@ -819,6 +825,92 @@ function enableDebug () {
819
825
  }
820
826
  }
821
827
  });
828
+ require.register("vue/src/fragment.js", function(exports, require, module){
829
+ // string -> DOM conversion
830
+ // wrappers originally from jQuery, scooped from component/domify
831
+ var map = {
832
+ legend : [1, '<fieldset>', '</fieldset>'],
833
+ tr : [2, '<table><tbody>', '</tbody></table>'],
834
+ col : [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
835
+ _default : [0, '', '']
836
+ }
837
+
838
+ map.td =
839
+ map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']
840
+
841
+ map.option =
842
+ map.optgroup = [1, '<select multiple="multiple">', '</select>']
843
+
844
+ map.thead =
845
+ map.tbody =
846
+ map.colgroup =
847
+ map.caption =
848
+ map.tfoot = [1, '<table>', '</table>']
849
+
850
+ map.text =
851
+ map.circle =
852
+ map.ellipse =
853
+ map.line =
854
+ map.path =
855
+ map.polygon =
856
+ map.polyline =
857
+ map.rect = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']
858
+
859
+ var TAG_RE = /<([\w:]+)/
860
+
861
+ module.exports = function (template) {
862
+
863
+ if (typeof template !== 'string') {
864
+ return template
865
+ }
866
+
867
+ // template by ID
868
+ if (template.charAt(0) === '#') {
869
+ var templateNode = document.getElementById(template.slice(1))
870
+ if (!templateNode) return
871
+ // if its a template tag and the browser supports it,
872
+ // its content is already a document fragment!
873
+ if (templateNode.tagName === 'TEMPLATE' && templateNode.content) {
874
+ return templateNode.content
875
+ }
876
+ template = templateNode.innerHTML
877
+ }
878
+
879
+ var frag = document.createDocumentFragment(),
880
+ m = TAG_RE.exec(template)
881
+ // text only
882
+ if (!m) {
883
+ frag.appendChild(document.createTextNode(template))
884
+ return frag
885
+ }
886
+
887
+ var tag = m[1],
888
+ wrap = map[tag] || map._default,
889
+ depth = wrap[0],
890
+ prefix = wrap[1],
891
+ suffix = wrap[2],
892
+ node = document.createElement('div')
893
+
894
+ node.innerHTML = prefix + template.trim() + suffix
895
+ while (depth--) node = node.lastChild
896
+
897
+ // one element
898
+ if (node.firstChild === node.lastChild) {
899
+ frag.appendChild(node.firstChild)
900
+ return frag
901
+ }
902
+
903
+ // multiple nodes, return a fragment
904
+ var child
905
+ /* jshint boss: true */
906
+ while (child = node.firstChild) {
907
+ if (node.nodeType === 1) {
908
+ frag.appendChild(child)
909
+ }
910
+ }
911
+ return frag
912
+ }
913
+ });
822
914
  require.register("vue/src/compiler.js", function(exports, require, module){
823
915
  var Emitter = require('./emitter'),
824
916
  Observer = require('./observer'),
@@ -1044,8 +1136,8 @@ CompilerProto.setupElement = function (options) {
1044
1136
  }
1045
1137
  // replace option: use the first node in
1046
1138
  // the template directly
1047
- if (options.replace && template.childNodes.length === 1) {
1048
- replacer = template.childNodes[0].cloneNode(true)
1139
+ if (options.replace && template.firstChild === template.lastChild) {
1140
+ replacer = template.firstChild.cloneNode(true)
1049
1141
  if (el.parentNode) {
1050
1142
  el.parentNode.insertBefore(replacer, el)
1051
1143
  el.parentNode.removeChild(el)
@@ -1503,7 +1595,7 @@ CompilerProto.bindDirective = function (directive, bindingOwner) {
1503
1595
  directive.bind(value)
1504
1596
  }
1505
1597
  // set initial value
1506
- directive.update(value, true)
1598
+ directive.$update(value, true)
1507
1599
  }
1508
1600
 
1509
1601
  /**
@@ -1777,7 +1869,7 @@ CompilerProto.destroy = function () {
1777
1869
  if (j > -1) dirs.splice(j, 1)
1778
1870
  }
1779
1871
  }
1780
- dir.unbind()
1872
+ dir.$unbind()
1781
1873
  }
1782
1874
 
1783
1875
  // unbind all computed, anonymous bindings
@@ -1934,7 +2026,7 @@ def(VMProto, '$broadcast', function () {
1934
2026
  child
1935
2027
  while (i--) {
1936
2028
  child = children[i]
1937
- child.emitter.emit.apply(child.emitter, arguments)
2029
+ child.emitter.applyEmit.apply(child.emitter, arguments)
1938
2030
  child.vm.$broadcast.apply(child.vm, arguments)
1939
2031
  }
1940
2032
  })
@@ -1946,7 +2038,7 @@ def(VMProto, '$dispatch', function () {
1946
2038
  var compiler = this.$compiler,
1947
2039
  emitter = compiler.emitter,
1948
2040
  parent = compiler.parent
1949
- emitter.emit.apply(emitter, arguments)
2041
+ emitter.applyEmit.apply(emitter, arguments)
1950
2042
  if (parent) {
1951
2043
  parent.vm.$dispatch.apply(parent.vm, arguments)
1952
2044
  }
@@ -1956,9 +2048,15 @@ def(VMProto, '$dispatch', function () {
1956
2048
  * delegate on/off/once to the compiler's emitter
1957
2049
  */
1958
2050
  ;['emit', 'on', 'off', 'once'].forEach(function (method) {
2051
+ // internal emit has fixed number of arguments.
2052
+ // exposed emit uses the external version
2053
+ // with fn.apply.
2054
+ var realMethod = method === 'emit'
2055
+ ? 'applyEmit'
2056
+ : method
1959
2057
  def(VMProto, '$' + method, function () {
1960
2058
  var emitter = this.$compiler.emitter
1961
- emitter[method].apply(emitter, arguments)
2059
+ emitter[realMethod].apply(emitter, arguments)
1962
2060
  })
1963
2061
  })
1964
2062
 
@@ -2068,7 +2166,7 @@ BindingProto._update = function () {
2068
2166
  var i = this.dirs.length,
2069
2167
  value = this.val()
2070
2168
  while (i--) {
2071
- this.dirs[i].update(value)
2169
+ this.dirs[i].$update(value)
2072
2170
  }
2073
2171
  this.pub()
2074
2172
  }
@@ -2105,7 +2203,7 @@ BindingProto.unbind = function () {
2105
2203
  this.unbound = true
2106
2204
  var i = this.dirs.length
2107
2205
  while (i--) {
2108
- this.dirs[i].unbind()
2206
+ this.dirs[i].$unbind()
2109
2207
  }
2110
2208
  i = this.deps.length
2111
2209
  var subs
@@ -2255,9 +2353,7 @@ var ObjProxy = Object.create(Object.prototype)
2255
2353
  def(ObjProxy, '$add', function (key, val) {
2256
2354
  if (hasOwn.call(this, key)) return
2257
2355
  this[key] = val
2258
- convertKey(this, key)
2259
- // emit a propagating set event
2260
- this.__emitter__.emit('set', key, val, true)
2356
+ convertKey(this, key, true)
2261
2357
  }, !hasProto)
2262
2358
 
2263
2359
  def(ObjProxy, '$delete', function (key) {
@@ -2356,7 +2452,7 @@ function watchArray (arr) {
2356
2452
  * so it emits get/set events.
2357
2453
  * Then watch the value itself.
2358
2454
  */
2359
- function convertKey (obj, key) {
2455
+ function convertKey (obj, key, propagate) {
2360
2456
  var keyPrefix = key.charAt(0)
2361
2457
  if (keyPrefix === '$' || keyPrefix === '_') {
2362
2458
  return
@@ -2367,7 +2463,7 @@ function convertKey (obj, key) {
2367
2463
  var emitter = obj.__emitter__,
2368
2464
  values = emitter.values
2369
2465
 
2370
- init(obj[key])
2466
+ init(obj[key], propagate)
2371
2467
 
2372
2468
  oDef(obj, key, {
2373
2469
  enumerable: true,
@@ -2596,14 +2692,10 @@ function Directive (name, ast, definition, compiler, el) {
2596
2692
 
2597
2693
  // mix in properties from the directive definition
2598
2694
  if (typeof definition === 'function') {
2599
- this[isEmpty ? 'bind' : '_update'] = definition
2695
+ this[isEmpty ? 'bind' : 'update'] = definition
2600
2696
  } else {
2601
2697
  for (var prop in definition) {
2602
- if (prop === 'unbind' || prop === 'update') {
2603
- this['_' + prop] = definition[prop]
2604
- } else {
2605
- this[prop] = definition[prop]
2606
- }
2698
+ this[prop] = definition[prop]
2607
2699
  }
2608
2700
  }
2609
2701
 
@@ -2659,13 +2751,14 @@ var DirProto = Directive.prototype
2659
2751
  * for computed properties, this will only be called once
2660
2752
  * during initialization.
2661
2753
  */
2662
- DirProto.update = function (value, init) {
2754
+ DirProto.$update = function (value, init) {
2755
+ if (this.$lock) return
2663
2756
  if (init || value !== this.value || (value && typeof value === 'object')) {
2664
2757
  this.value = value
2665
- if (this._update) {
2666
- this._update(
2758
+ if (this.update) {
2759
+ this.update(
2667
2760
  this.filters && !this.computeFilters
2668
- ? this.applyFilters(value)
2761
+ ? this.$applyFilters(value)
2669
2762
  : value,
2670
2763
  init
2671
2764
  )
@@ -2676,7 +2769,7 @@ DirProto.update = function (value, init) {
2676
2769
  /**
2677
2770
  * pipe the value through filters
2678
2771
  */
2679
- DirProto.applyFilters = function (value) {
2772
+ DirProto.$applyFilters = function (value) {
2680
2773
  var filtered = value, filter
2681
2774
  for (var i = 0, l = this.filters.length; i < l; i++) {
2682
2775
  filter = this.filters[i]
@@ -2688,10 +2781,10 @@ DirProto.applyFilters = function (value) {
2688
2781
  /**
2689
2782
  * Unbind diretive
2690
2783
  */
2691
- DirProto.unbind = function () {
2784
+ DirProto.$unbind = function () {
2692
2785
  // this can be called before the el is even assigned...
2693
2786
  if (!this.el || !this.vm) return
2694
- if (this._unbind) this._unbind()
2787
+ if (this.unbind) this.unbind()
2695
2788
  this.vm = this.el = this.binding = this.compiler = null
2696
2789
  }
2697
2790
 
@@ -2855,7 +2948,7 @@ var KEYWORDS =
2855
2948
  ',Math',
2856
2949
 
2857
2950
  KEYWORDS_RE = new RegExp(["\\b" + KEYWORDS.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g'),
2858
- REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,
2951
+ REMOVE_RE = /\/\*(?:.|\n)*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|'[^']*'|"[^"]*"|[\s\t\n]*\.[\s\t\n]*[$\w\.]+|[\{,]\s*[\w\$_]+\s*:/g,
2859
2952
  SPLIT_RE = /[^\w$]+/g,
2860
2953
  NUMBER_RE = /\b\d[^,]*/g,
2861
2954
  BOUNDARY_RE = /^,+|,+$/g
@@ -3818,7 +3911,7 @@ module.exports = {
3818
3911
  update: function (value) {
3819
3912
 
3820
3913
  if (!value) {
3821
- this._unbind()
3914
+ this.unbind()
3822
3915
  } else if (!this.childVM) {
3823
3916
  this.childVM = new this.Ctor({
3824
3917
  el: this.el.cloneNode(true),
@@ -4056,16 +4149,6 @@ module.exports = {
4056
4149
  (raw || data).__emitter__[this.identifier] = true
4057
4150
  }
4058
4151
 
4059
- if (wrap) {
4060
- var self = this,
4061
- sync = function (val) {
4062
- self.lock = true
4063
- self.collection.$set(vm.$index, val)
4064
- self.lock = false
4065
- }
4066
- vm.$compiler.observer.on('change:' + alias, sync)
4067
- }
4068
-
4069
4152
  return vm
4070
4153
 
4071
4154
  },
@@ -4120,7 +4203,7 @@ module.exports = {
4120
4203
  utils.warn('Directive "v-on:' + this.expression + '" expects a method.')
4121
4204
  return
4122
4205
  }
4123
- this._unbind()
4206
+ this.unbind()
4124
4207
  var vm = this.vm,
4125
4208
  context = this.context
4126
4209
  this.handler = function (e) {
@@ -4367,7 +4450,7 @@ module.exports = {
4367
4450
  }
4368
4451
  });
4369
4452
  require.register("vue/src/directives/html.js", function(exports, require, module){
4370
- var guard = require('../utils').guard,
4453
+ var utils = require('../utils'),
4371
4454
  slice = [].slice
4372
4455
 
4373
4456
  /**
@@ -4380,14 +4463,13 @@ module.exports = {
4380
4463
  // {{{ inline unescaped html }}}
4381
4464
  if (this.el.nodeType === 8) {
4382
4465
  // hold nodes
4383
- this.holder = document.createElement('div')
4384
4466
  this.nodes = []
4385
4467
  }
4386
4468
  },
4387
4469
 
4388
4470
  update: function (value) {
4389
- value = guard(value)
4390
- if (this.holder) {
4471
+ value = utils.guard(value)
4472
+ if (this.nodes) {
4391
4473
  this.swap(value)
4392
4474
  } else {
4393
4475
  this.el.innerHTML = value
@@ -4396,17 +4478,17 @@ module.exports = {
4396
4478
 
4397
4479
  swap: function (value) {
4398
4480
  var parent = this.el.parentNode,
4399
- holder = this.holder,
4400
- nodes = this.nodes,
4401
- i = nodes.length, l
4481
+ nodes = this.nodes,
4482
+ i = nodes.length
4483
+ // remove old nodes
4402
4484
  while (i--) {
4403
4485
  parent.removeChild(nodes[i])
4404
4486
  }
4405
- holder.innerHTML = value
4406
- nodes = this.nodes = slice.call(holder.childNodes)
4407
- for (i = 0, l = nodes.length; i < l; i++) {
4408
- parent.insertBefore(nodes[i], this.el)
4409
- }
4487
+ // convert new value to a fragment
4488
+ var frag = utils.toFragment(value)
4489
+ // save a reference to these nodes so we can remove later
4490
+ this.nodes = slice.call(frag.childNodes)
4491
+ parent.insertBefore(frag, this.el)
4410
4492
  }
4411
4493
  }
4412
4494
  });
@@ -4536,7 +4618,7 @@ module.exports = {
4536
4618
 
4537
4619
  update: function(value) {
4538
4620
 
4539
- this._unbind()
4621
+ this.unbind()
4540
4622
 
4541
4623
  var Ctor = this.compiler.getOption('components', value)
4542
4624
  if (!Ctor) return
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vuejs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Butler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-04-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple asset-pipeline wrapper for vue.js by Evan You
14
14
  email: