riot_js-rails 0.5.0 → 0.6.0
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 +4 -4
- data/lib/riot_js/rails/version.rb +1 -1
- data/vendor/assets/javascripts/riot.js +92 -68
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc280c7260688d2ddb9b3deec40b11123a6690f
|
4
|
+
data.tar.gz: 920ceb13004543b2a931b40207ca9bba58d627fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc05701c5afdc4b1dc58c4a87642eb6eed11bd0367a0bcc50a35422d4c82c9b541c9ee89a5e23c45c706a0d0213b9c79df062ae64b37db6aadabf4438427573
|
7
|
+
data.tar.gz: 007a8b1301a89a1b592ae7166a72e3027162b2cfbe764dbbc5d3073d7f5bd67abbef51b3bf627208f9182879faa3f3028b244417a86cf3393da07abe09df8610
|
@@ -1,8 +1,8 @@
|
|
1
|
-
/* Riot v2.
|
1
|
+
/* Riot v2.6.1, @license MIT */
|
2
2
|
|
3
3
|
;(function(window, undefined) {
|
4
4
|
'use strict';
|
5
|
-
var riot = { version: 'v2.
|
5
|
+
var riot = { version: 'v2.6.1', settings: {} },
|
6
6
|
// be aware, internal usage
|
7
7
|
// ATTENTION: prefix the global dynamic variables with `__`
|
8
8
|
|
@@ -28,6 +28,8 @@ var riot = { version: 'v2.5.0', settings: {} },
|
|
28
28
|
T_OBJECT = 'object',
|
29
29
|
T_UNDEF = 'undefined',
|
30
30
|
T_FUNCTION = 'function',
|
31
|
+
XLINK_NS = 'http://www.w3.org/1999/xlink',
|
32
|
+
XLINK_REGEX = /^xlink:(\w+)/,
|
31
33
|
// special native tags that cannot be treated like the others
|
32
34
|
SPECIAL_TAGS_REGEX = /^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?|opt(?:ion|group))$/,
|
33
35
|
RESERVED_WORDS_BLACKLIST = /^(?:_(?:item|id|parent)|update|root|(?:un)?mount|mixin|is(?:Mounted|Loop)|tags|parent|opts|trigger|o(?:n|ff|ne))$/,
|
@@ -65,11 +67,10 @@ riot.observable = function(el) {
|
|
65
67
|
* @param {Function} fn - callback
|
66
68
|
*/
|
67
69
|
function onEachEvent(e, fn) {
|
68
|
-
var es = e.split(' '), l = es.length, i = 0
|
70
|
+
var es = e.split(' '), l = es.length, i = 0
|
69
71
|
for (; i < l; i++) {
|
70
|
-
name = es[i]
|
71
|
-
|
72
|
-
if (name) fn( ~indx ? name.substring(0, indx) : name, i, ~indx ? name.slice(indx + 1) : null)
|
72
|
+
var name = es[i]
|
73
|
+
if (name) fn(name, i)
|
73
74
|
}
|
74
75
|
}
|
75
76
|
|
@@ -90,10 +91,9 @@ riot.observable = function(el) {
|
|
90
91
|
value: function(events, fn) {
|
91
92
|
if (typeof fn != 'function') return el
|
92
93
|
|
93
|
-
onEachEvent(events, function(name, pos
|
94
|
+
onEachEvent(events, function(name, pos) {
|
94
95
|
(callbacks[name] = callbacks[name] || []).push(fn)
|
95
96
|
fn.typed = pos > 0
|
96
|
-
fn.ns = ns
|
97
97
|
})
|
98
98
|
|
99
99
|
return el
|
@@ -113,11 +113,11 @@ riot.observable = function(el) {
|
|
113
113
|
value: function(events, fn) {
|
114
114
|
if (events == '*' && !fn) callbacks = {}
|
115
115
|
else {
|
116
|
-
onEachEvent(events, function(name, pos
|
117
|
-
if (fn
|
116
|
+
onEachEvent(events, function(name, pos) {
|
117
|
+
if (fn) {
|
118
118
|
var arr = callbacks[name]
|
119
119
|
for (var i = 0, cb; cb = arr && arr[i]; ++i) {
|
120
|
-
if (cb == fn
|
120
|
+
if (cb == fn) arr.splice(i--, 1)
|
121
121
|
}
|
122
122
|
} else delete callbacks[name]
|
123
123
|
})
|
@@ -167,14 +167,14 @@ riot.observable = function(el) {
|
|
167
167
|
args[i] = arguments[i + 1] // skip first argument
|
168
168
|
}
|
169
169
|
|
170
|
-
onEachEvent(events, function(name, pos
|
170
|
+
onEachEvent(events, function(name, pos) {
|
171
171
|
|
172
172
|
fns = slice.call(callbacks[name] || [], 0)
|
173
173
|
|
174
174
|
for (var i = 0, fn; fn = fns[i]; ++i) {
|
175
175
|
if (fn.busy) continue
|
176
176
|
fn.busy = 1
|
177
|
-
|
177
|
+
fn.apply(el, fn.typed ? [name].concat(args) : args)
|
178
178
|
if (fns[i] !== fn) { i-- }
|
179
179
|
fn.busy = 0
|
180
180
|
}
|
@@ -314,7 +314,7 @@ function getPathFromBase(href) {
|
|
314
314
|
|
315
315
|
function emit(force) {
|
316
316
|
// the stack is needed for redirections
|
317
|
-
var isRoot = emitStackLevel == 0
|
317
|
+
var isRoot = emitStackLevel == 0, first
|
318
318
|
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return
|
319
319
|
|
320
320
|
emitStackLevel++
|
@@ -326,10 +326,7 @@ function emit(force) {
|
|
326
326
|
}
|
327
327
|
})
|
328
328
|
if (isRoot) {
|
329
|
-
while (emitStack.
|
330
|
-
emitStack[0]()
|
331
|
-
emitStack.shift()
|
332
|
-
}
|
329
|
+
while (first = emitStack.shift()) first() // stack increses within this call
|
333
330
|
emitStackLevel = 0
|
334
331
|
}
|
335
332
|
}
|
@@ -352,13 +349,13 @@ function click(e) {
|
|
352
349
|
|| el.href.indexOf(loc.href.match(RE_ORIGIN)[0]) == -1 // cross origin
|
353
350
|
) return
|
354
351
|
|
355
|
-
if (el.href != loc.href
|
356
|
-
|
352
|
+
if (el.href != loc.href
|
353
|
+
&& (
|
357
354
|
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|
358
|
-
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|
355
|
+
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|
356
|
+
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|
359
357
|
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
|
360
|
-
) return
|
361
|
-
}
|
358
|
+
)) return
|
362
359
|
|
363
360
|
e.preventDefault()
|
364
361
|
}
|
@@ -371,22 +368,20 @@ function click(e) {
|
|
371
368
|
* @returns {boolean} - route not found flag
|
372
369
|
*/
|
373
370
|
function go(path, title, shouldReplace) {
|
374
|
-
if (hist) { // if a browser
|
375
|
-
path = base + normalize(path)
|
376
|
-
title = title || doc.title
|
377
|
-
// browsers ignores the second parameter `title`
|
378
|
-
shouldReplace
|
379
|
-
? hist.replaceState(null, title, path)
|
380
|
-
: hist.pushState(null, title, path)
|
381
|
-
// so we need to set it manually
|
382
|
-
doc.title = title
|
383
|
-
routeFound = false
|
384
|
-
emit()
|
385
|
-
return routeFound
|
386
|
-
}
|
387
|
-
|
388
371
|
// Server-side usage: directly execute handlers for the path
|
389
|
-
return central[TRIGGER]('emit', getPathFromBase(path))
|
372
|
+
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
|
373
|
+
|
374
|
+
path = base + normalize(path)
|
375
|
+
title = title || doc.title
|
376
|
+
// browsers ignores the second parameter `title`
|
377
|
+
shouldReplace
|
378
|
+
? hist.replaceState(null, title, path)
|
379
|
+
: hist.pushState(null, title, path)
|
380
|
+
// so we need to set it manually
|
381
|
+
doc.title = title
|
382
|
+
routeFound = false
|
383
|
+
emit()
|
384
|
+
return routeFound
|
390
385
|
}
|
391
386
|
|
392
387
|
/**
|
@@ -538,7 +533,7 @@ riot.route = route
|
|
538
533
|
|
539
534
|
/**
|
540
535
|
* The riot template engine
|
541
|
-
* @version v2.4.
|
536
|
+
* @version v2.4.1
|
542
537
|
*/
|
543
538
|
/**
|
544
539
|
* riot.util.brackets
|
@@ -562,6 +557,10 @@ var brackets = (function (UNDEF) {
|
|
562
557
|
/(?:\breturn\s+|(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/]))/.source + '|' +
|
563
558
|
/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,
|
564
559
|
|
560
|
+
UNSUPPORTED = RegExp('[\\' + 'x00-\\x1F<>a-zA-Z0-9\'",;\\\\]'),
|
561
|
+
|
562
|
+
NEED_ESCAPE = /(?=[[\]()*+?.^$|])/g,
|
563
|
+
|
565
564
|
FINDBRACES = {
|
566
565
|
'(': RegExp('([()])|' + S_QBLOCKS, REGLOB),
|
567
566
|
'[': RegExp('([[\\]])|' + S_QBLOCKS, REGLOB),
|
@@ -602,10 +601,10 @@ var brackets = (function (UNDEF) {
|
|
602
601
|
|
603
602
|
var arr = pair.split(' ')
|
604
603
|
|
605
|
-
if (arr.length !== 2 ||
|
604
|
+
if (arr.length !== 2 || UNSUPPORTED.test(pair)) {
|
606
605
|
throw new Error('Unsupported brackets "' + pair + '"')
|
607
606
|
}
|
608
|
-
arr = arr.concat(pair.replace(
|
607
|
+
arr = arr.concat(pair.replace(NEED_ESCAPE, '\\').split(' '))
|
609
608
|
|
610
609
|
arr[4] = _rewrite(arr[1].length > 1 ? /{[\S\s]*?}/ : _pairs[4], arr)
|
611
610
|
arr[5] = _rewrite(pair.length > 3 ? /\\({|})/g : _pairs[5], arr)
|
@@ -765,6 +764,9 @@ var tmpl = (function () {
|
|
765
764
|
|
766
765
|
_tmpl.loopKeys = brackets.loopKeys
|
767
766
|
|
767
|
+
// istanbul ignore next
|
768
|
+
_tmpl.clearCache = function () { _cache = {} }
|
769
|
+
|
768
770
|
_tmpl.errorHandler = null
|
769
771
|
|
770
772
|
function _logErr (err, ctx) {
|
@@ -784,10 +786,7 @@ var tmpl = (function () {
|
|
784
786
|
|
785
787
|
if (expr.slice(0, 11) !== 'try{return ') expr = 'return ' + expr
|
786
788
|
|
787
|
-
|
788
|
-
|
789
|
-
return new Function('E', expr + ';')
|
790
|
-
/* eslint-enable */
|
789
|
+
return new Function('E', expr + ';') // eslint-disable-line no-new-func
|
791
790
|
}
|
792
791
|
|
793
792
|
var
|
@@ -907,7 +906,7 @@ var tmpl = (function () {
|
|
907
906
|
// istanbul ignore next: not both
|
908
907
|
var // eslint-disable-next-line max-len
|
909
908
|
JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').',
|
910
|
-
JS_VARNAME = /[,{][$\w]
|
909
|
+
JS_VARNAME = /[,{][$\w]+(?=:)|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g,
|
911
910
|
JS_NOPROPS = /^(?=(\.[$\w]+))\1(?:[^.[(]|$)/
|
912
911
|
|
913
912
|
function _wrapExpr (expr, asText, key) {
|
@@ -947,10 +946,7 @@ var tmpl = (function () {
|
|
947
946
|
return expr
|
948
947
|
}
|
949
948
|
|
950
|
-
|
951
|
-
_tmpl.parse = function (s) { return s }
|
952
|
-
|
953
|
-
_tmpl.version = brackets.version = 'v2.4.0'
|
949
|
+
_tmpl.version = brackets.version = 'v2.4.1'
|
954
950
|
|
955
951
|
return _tmpl
|
956
952
|
|
@@ -1262,7 +1258,7 @@ function _each(dom, parent, expr) {
|
|
1262
1258
|
// update the DOM
|
1263
1259
|
if (isVirtual)
|
1264
1260
|
moveVirtual(tag, root, tags[i], dom.childNodes.length)
|
1265
|
-
else root.insertBefore(tag.root, tags[i].root)
|
1261
|
+
else if (tags[i].root.parentNode) root.insertBefore(tag.root, tags[i].root)
|
1266
1262
|
// update the position attribute if it exists
|
1267
1263
|
if (expr.pos)
|
1268
1264
|
tag[expr.pos] = i
|
@@ -1506,16 +1502,16 @@ function Tag(impl, conf, innerHTML) {
|
|
1506
1502
|
}
|
1507
1503
|
}
|
1508
1504
|
|
1509
|
-
function
|
1510
|
-
|
1511
|
-
each(Object.keys(self.parent), function(k) {
|
1505
|
+
function inheritFrom(target) {
|
1506
|
+
each(Object.keys(target), function(k) {
|
1512
1507
|
// some properties must be always in sync with the parent tag
|
1513
1508
|
var mustSync = !RESERVED_WORDS_BLACKLIST.test(k) && contains(propsInSyncWithParent, k)
|
1509
|
+
|
1514
1510
|
if (typeof self[k] === T_UNDEF || mustSync) {
|
1515
1511
|
// track the property to keep in sync
|
1516
1512
|
// so we can keep it updated
|
1517
1513
|
if (!mustSync) propsInSyncWithParent.push(k)
|
1518
|
-
self[k] =
|
1514
|
+
self[k] = target[k]
|
1519
1515
|
}
|
1520
1516
|
})
|
1521
1517
|
}
|
@@ -1531,8 +1527,10 @@ function Tag(impl, conf, innerHTML) {
|
|
1531
1527
|
// make sure the data passed will not override
|
1532
1528
|
// the component core methods
|
1533
1529
|
data = cleanUpData(data)
|
1534
|
-
// inherit properties from the parent
|
1535
|
-
|
1530
|
+
// inherit properties from the parent in loop
|
1531
|
+
if (isLoop) {
|
1532
|
+
inheritFrom(self.parent)
|
1533
|
+
}
|
1536
1534
|
// normalize the tag properties in case an item object was initially passed
|
1537
1535
|
if (data && isObject(item)) {
|
1538
1536
|
normalizeData(data)
|
@@ -1576,11 +1574,21 @@ function Tag(impl, conf, innerHTML) {
|
|
1576
1574
|
// loop the keys in the function prototype or the all object keys
|
1577
1575
|
each(props, function(key) {
|
1578
1576
|
// bind methods to self
|
1579
|
-
|
1577
|
+
// allow mixins to override other properties/parent mixins
|
1578
|
+
if (key != 'init') {
|
1579
|
+
// check for getters/setters
|
1580
|
+
var descriptor = Object.getOwnPropertyDescriptor(instance, key)
|
1581
|
+
var hasGetterSetter = descriptor && (descriptor.get || descriptor.set)
|
1582
|
+
|
1580
1583
|
// apply method only if it does not already exist on the instance
|
1581
|
-
self
|
1582
|
-
|
1583
|
-
|
1584
|
+
if (!self.hasOwnProperty(key) && hasGetterSetter) {
|
1585
|
+
Object.defineProperty(self, key, descriptor)
|
1586
|
+
} else {
|
1587
|
+
self[key] = isFunction(instance[key]) ?
|
1588
|
+
instance[key].bind(self) :
|
1589
|
+
instance[key]
|
1590
|
+
}
|
1591
|
+
}
|
1584
1592
|
})
|
1585
1593
|
|
1586
1594
|
// init method will be called automatically
|
@@ -1595,11 +1603,17 @@ function Tag(impl, conf, innerHTML) {
|
|
1595
1603
|
|
1596
1604
|
// add global mixins
|
1597
1605
|
var globalMixin = riot.mixin(GLOBAL_MIXIN)
|
1606
|
+
|
1598
1607
|
if (globalMixin)
|
1599
1608
|
for (var i in globalMixin)
|
1600
1609
|
if (globalMixin.hasOwnProperty(i))
|
1601
1610
|
self.mixin(globalMixin[i])
|
1602
1611
|
|
1612
|
+
// children in loop should inherit from true parent
|
1613
|
+
if (self._parent) {
|
1614
|
+
inheritFrom(self._parent)
|
1615
|
+
}
|
1616
|
+
|
1603
1617
|
// initialiation
|
1604
1618
|
if (impl.fn) impl.fn.call(self, opts)
|
1605
1619
|
|
@@ -1806,7 +1820,7 @@ function update(expressions, tag) {
|
|
1806
1820
|
var dom = expr.dom,
|
1807
1821
|
attrName = expr.attr,
|
1808
1822
|
value = tmpl(expr.expr, tag),
|
1809
|
-
parent = expr.dom.parentNode
|
1823
|
+
parent = expr.parent || expr.dom.parentNode
|
1810
1824
|
|
1811
1825
|
if (expr.bool) {
|
1812
1826
|
value = !!value
|
@@ -1828,6 +1842,9 @@ function update(expressions, tag) {
|
|
1828
1842
|
value += ''
|
1829
1843
|
// test for parent avoids error with invalid assignment to nodeValue
|
1830
1844
|
if (parent) {
|
1845
|
+
// cache the parent node because somehow it will become null on IE
|
1846
|
+
// on the next iteration
|
1847
|
+
expr.parent = parent
|
1831
1848
|
if (parent.tagName === 'TEXTAREA') {
|
1832
1849
|
parent.value = value // #1113
|
1833
1850
|
if (!IE_VERSION) dom.nodeValue = value // #1625 IE throws here, nodeValue
|
@@ -1839,13 +1856,16 @@ function update(expressions, tag) {
|
|
1839
1856
|
|
1840
1857
|
// ~~#1612: look for changes in dom.value when updating the value~~
|
1841
1858
|
if (attrName === 'value') {
|
1842
|
-
dom.value
|
1859
|
+
if (dom.value !== value) {
|
1860
|
+
dom.value = value
|
1861
|
+
setAttr(dom, attrName, value)
|
1862
|
+
}
|
1843
1863
|
return
|
1864
|
+
} else {
|
1865
|
+
// remove original attribute
|
1866
|
+
remAttr(dom, attrName)
|
1844
1867
|
}
|
1845
1868
|
|
1846
|
-
// remove original attribute
|
1847
|
-
remAttr(dom, attrName)
|
1848
|
-
|
1849
1869
|
// event handler
|
1850
1870
|
if (isFunction(value)) {
|
1851
1871
|
setEventHandler(attrName, value, dom, tag)
|
@@ -2013,13 +2033,17 @@ function getAttr(dom, name) {
|
|
2013
2033
|
}
|
2014
2034
|
|
2015
2035
|
/**
|
2016
|
-
* Set any DOM attribute
|
2036
|
+
* Set any DOM/SVG attribute
|
2017
2037
|
* @param { Object } dom - DOM node we want to update
|
2018
2038
|
* @param { String } name - name of the property we want to set
|
2019
2039
|
* @param { String } val - value of the property we want to set
|
2020
2040
|
*/
|
2021
2041
|
function setAttr(dom, name, val) {
|
2022
|
-
|
2042
|
+
var xlink = XLINK_REGEX.exec(name)
|
2043
|
+
if (xlink && xlink[1])
|
2044
|
+
dom.setAttributeNS(XLINK_NS, xlink[1], val)
|
2045
|
+
else
|
2046
|
+
dom.setAttribute(name, val)
|
2023
2047
|
}
|
2024
2048
|
|
2025
2049
|
/**
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot_js-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Jaroszewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -167,4 +167,3 @@ signing_key:
|
|
167
167
|
specification_version: 4
|
168
168
|
summary: Muut Riot integration with Rails.
|
169
169
|
test_files: []
|
170
|
-
has_rdoc:
|