spyne 0.19.1 → 0.20.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.
- package/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +76 -86
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.umd.js +9565 -0
- package/package.json +47 -27
- package/rollup.config.js +26 -0
- package/src/spyne/channels/channel-fetch-class.js +39 -43
- package/src/spyne/channels/channel-payload-class.js +61 -74
- package/src/spyne/channels/channel-proxy.js +25 -26
- package/src/spyne/channels/channel.js +141 -149
- package/src/spyne/channels/channels-config.js +46 -47
- package/src/spyne/channels/channels-map.js +61 -65
- package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
- package/src/spyne/channels/spyne-channel-route.js +241 -250
- package/src/spyne/channels/spyne-channel-ui.js +213 -75
- package/src/spyne/channels/spyne-channel-window.js +157 -157
- package/src/spyne/spyne-app.js +32 -19
- package/src/spyne/spyne-plugins.js +55 -70
- package/src/spyne/spyne.js +23 -23
- package/src/spyne/utils/channel-config-validator.js +10 -10
- package/src/spyne/utils/channel-fetch-util.js +72 -55
- package/src/spyne/utils/channel-payload-filter.js +89 -100
- package/src/spyne/utils/deep-merge.js +31 -29
- package/src/spyne/utils/frp-tools.js +108 -92
- package/src/spyne/utils/gc.js +6 -6
- package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
- package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
- package/src/spyne/utils/route-channel-updater.js +23 -29
- package/src/spyne/utils/safe-clone.js +40 -58
- package/src/spyne/utils/sanitize-html.js +35 -0
- package/src/spyne/utils/security-policy.js +11 -0
- package/src/spyne/utils/spyne-app-properties.js +110 -114
- package/src/spyne/utils/spyne-logger.js +4 -11
- package/src/spyne/utils/spyne-plugins-methods.js +38 -63
- package/src/spyne/utils/spyne-trait.js +33 -33
- package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
- package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
- package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
- package/src/spyne/utils/viewstream-animations.js +12 -12
- package/src/spyne/utils/viewstream-observables.js +45 -45
- package/src/spyne/views/dom-element-template.js +111 -114
- package/src/spyne/views/dom-element.js +82 -84
- package/src/spyne/views/view-stream-broadcaster.js +66 -62
- package/src/spyne/views/view-stream-element.js +105 -106
- package/src/spyne/views/view-stream-payload.js +25 -27
- package/src/spyne/views/view-stream-selector.js +157 -163
- package/src/spyne/views/view-stream.js +416 -640
- package/src/tests/channels/channel-dom.test.js +15 -15
- package/src/tests/channels/channel-fetch.test.js +51 -62
- package/src/tests/channels/channel-payload-class.test.js +50 -63
- package/src/tests/channels/channel-payload-filter.test.js +133 -193
- package/src/tests/channels/channel-route.test.js +102 -112
- package/src/tests/channels/channel-stream-item.test.js +19 -19
- package/src/tests/channels/channel-ui.test.js +15 -27
- package/src/tests/channels/channel-util-dom.test.js +31 -31
- package/src/tests/channels/channel.test.js +20 -25
- package/src/tests/channels/route-utils.test.js +61 -66
- package/src/tests/channels/url-utils.test.js +151 -151
- package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
- package/src/tests/import.test.js +5 -5
- package/src/tests/index.js +6 -7
- package/src/tests/index.test.js +6 -8
- package/src/tests/mocks/channel-payload-data.js +218 -220
- package/src/tests/mocks/enhancer.test.js +5 -5
- package/src/tests/mocks/payload-ui.js +87 -90
- package/src/tests/mocks/routes-data.js +264 -266
- package/src/tests/mocks/spyne-docs.mocks.js +3 -3
- package/src/tests/mocks/template-renderer.mocks.js +47 -47
- package/src/tests/mocks/utils-data.js +78 -79
- package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
- package/src/tests/mocks/window-events-arr.js +1 -1
- package/src/tests/package-json.spec.test.js +9 -0
- package/src/tests/spyne-app.test.js +15 -18
- package/src/tests/spyne-plugin.test.js +16 -20
- package/src/tests/utils/channel-action-filter.test.js +84 -86
- package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
- package/src/tests/utils/channel-fetch-util.test.js +64 -66
- package/src/tests/utils/frp-tools.test.js +19 -19
- package/src/tests/utils/plugins-methods.test.js +31 -55
- package/src/tests/utils/security.test.js +10 -0
- package/src/tests/utils/spyne-app-properties.test.js +4 -8
- package/src/tests/views/dom-el-selectors.test.js +112 -119
- package/src/tests/views/dom-el-template-proxy.test.js +7 -0
- package/src/tests/views/dom-el-template.test.js +186 -156
- package/src/tests/views/dom-el.test.js +58 -56
- package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
- package/src/tests/views/view-stream-enhancer.test.js +11 -11
- package/src/tests/views/view-stream.test.js +22 -33
- package/webpack.config.js +76 -67
- package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
- package/docs/DomItem.html +0 -298
- package/docs/DomItem_DomItem.html +0 -314
- package/docs/ViewStream.html +0 -2249
- package/docs/ViewStream_ViewStream.html +0 -503
- package/docs/custom/css/jsdoc-viewstream.css +0 -377
- package/docs/custom/layout.tmpl +0 -47
- package/docs/dom-item.js.html +0 -213
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -548
- package/docs/index-custom.html +0 -79
- package/docs/index.html +0 -82
- package/docs/jsdoc.config.json +0 -22
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs/view-stream.js.html +0 -767
|
@@ -1,97 +1,95 @@
|
|
|
1
|
-
import {head, compose, reject, split, isEmpty, lte, defaultTo, prop} from 'ramda'
|
|
2
|
-
import {SpyneAppProperties} from '../utils/spyne-app-properties'
|
|
1
|
+
import { head, compose, reject, split, isEmpty, lte, defaultTo, prop } from 'ramda'
|
|
2
|
+
import { SpyneAppProperties } from '../utils/spyne-app-properties'
|
|
3
3
|
|
|
4
4
|
function generateSpyneSelectorId(el) {
|
|
5
|
-
const num = () => Math.random().toString(36).replace(/\d/gm, '').substring(1,8)
|
|
6
|
-
let vsid = `${num()}
|
|
5
|
+
const num = () => Math.random().toString(36).replace(/\d/gm, '').substring(1, 8)
|
|
6
|
+
let vsid = `${num()}`
|
|
7
7
|
if (el.dataset.vsid === undefined) {
|
|
8
|
-
el.dataset.vsid = vsid
|
|
8
|
+
el.dataset.vsid = vsid
|
|
9
9
|
} else {
|
|
10
|
-
vsid = el.dataset.vsid
|
|
10
|
+
vsid = el.dataset.vsid
|
|
11
11
|
}
|
|
12
|
-
return `[data-vsid='${vsid}']
|
|
12
|
+
return `[data-vsid='${vsid}']`
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function isDevMode(){
|
|
16
|
-
return SpyneAppProperties.debug === true
|
|
15
|
+
function isDevMode() {
|
|
16
|
+
return SpyneAppProperties.debug === true
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return nodeCheck(el);
|
|
19
|
+
function isNodeElement(el) {
|
|
20
|
+
const nodeCheck = compose(lte(0), defaultTo(-1), prop('nodeType'))
|
|
21
|
+
return nodeCheck(el)
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
function getElOrList(cxt,
|
|
26
|
-
|
|
27
|
-
return list.length === 1 ? head(list) : list
|
|
28
|
-
}
|
|
24
|
+
function getElOrList(cxt, sel, verboseBool = false) {
|
|
25
|
+
const list = getNodeListArray(cxt, sel, verboseBool)
|
|
26
|
+
return list.length === 1 ? head(list) : list
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
function testSelectors(cxt,
|
|
31
|
-
|
|
29
|
+
function testSelectors(cxt, sel, verboseBool) {
|
|
30
|
+
const el = document.querySelector(cxt)
|
|
32
31
|
|
|
33
|
-
const elIsDomElement = compose(lte(0), defaultTo(-1),
|
|
34
|
-
prop('nodeType'));
|
|
32
|
+
const elIsDomElement = compose(lte(0), defaultTo(-1), prop('nodeType'))
|
|
35
33
|
|
|
36
34
|
if (el !== null && elIsDomElement(el) === false) {
|
|
37
|
-
console.warn(`Spyne Warning: the el object is not a valid single element, ${el}`)
|
|
38
|
-
return
|
|
35
|
+
console.warn(`Spyne Warning: the el object is not a valid single element, ${el}`)
|
|
36
|
+
return
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
if (sel !== undefined && String(sel).trim().length > 0) {
|
|
40
|
+
function isValidSelector(selector) {
|
|
41
|
+
try {
|
|
42
|
+
const elements = document.querySelectorAll(selector)
|
|
43
|
+
return elements.length > 0 // Returns true if the selector is valid and selects at least one element
|
|
44
|
+
} catch (e) {
|
|
45
|
+
return false // Catching an exception means the selector is invalid
|
|
46
46
|
}
|
|
47
|
+
}
|
|
47
48
|
|
|
49
|
+
const isValidSelectorBool = isValidSelector(sel)
|
|
50
|
+
if (verboseBool === true && isDevMode() === true && isValidSelectorBool === false) {
|
|
51
|
+
console.warn(`Spyne Warning: the selector, ${sel} does not exist in this el, ${cxt}`)
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
|
-
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
function getNodeListArray(cxt,
|
|
54
|
-
|
|
55
|
-
let isParent = false
|
|
56
|
-
|
|
56
|
+
function getNodeListArray(cxt, sel, verboseBool = false) {
|
|
57
|
+
const selector = sel !== undefined ? `${cxt} ${sel}` : cxt
|
|
58
|
+
let isParent = false
|
|
57
59
|
|
|
58
60
|
const returnSelectorIfValid = (selector) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const elArr = returnSelectorIfValid(selector);
|
|
76
|
-
|
|
77
|
-
if (verboseBool===true) {
|
|
78
|
-
const mainSel = isParent === true ? 'body' : cxt;
|
|
79
|
-
testSelectors(mainSel, str, verboseBool);
|
|
61
|
+
let arr = []
|
|
62
|
+
try {
|
|
63
|
+
arr = document.querySelectorAll(selector)
|
|
64
|
+
} catch (e) { arr = [] }
|
|
65
|
+
try {
|
|
66
|
+
isParent = document.querySelector(sel) === document.querySelector(cxt)
|
|
67
|
+
if (isParent === true) {
|
|
68
|
+
arr = [document.querySelector(sel)]
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
// return [];
|
|
72
|
+
}
|
|
73
|
+
return arr// document.querySelectorAll(selector);
|
|
80
74
|
}
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
const elArr = returnSelectorIfValid(selector)
|
|
84
77
|
|
|
78
|
+
if (verboseBool === true) {
|
|
79
|
+
const mainSel = isParent === true ? 'body' : cxt
|
|
80
|
+
testSelectors(mainSel, sel, verboseBool)
|
|
81
|
+
}
|
|
85
82
|
|
|
83
|
+
return elArr
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
function setInlineCss(val, cxt,
|
|
89
|
-
|
|
86
|
+
function setInlineCss(val, cxt, sel) {
|
|
87
|
+
const arr = getNodeListArray(cxt, sel)
|
|
90
88
|
const addInlineCss = item => {
|
|
91
|
-
item.style.cssText = val
|
|
92
|
-
}
|
|
93
|
-
arr.forEach(addInlineCss)
|
|
94
|
-
return this
|
|
89
|
+
item.style.cssText = val
|
|
90
|
+
}
|
|
91
|
+
arr.forEach(addInlineCss)
|
|
92
|
+
return this
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
/**
|
|
@@ -105,22 +103,21 @@ function setInlineCss(val, cxt, str) {
|
|
|
105
103
|
* @constructor
|
|
106
104
|
*/
|
|
107
105
|
|
|
108
|
-
function ViewStreamSelector(cxt,
|
|
109
|
-
cxt = typeof (cxt) === 'string' ? cxt : generateSpyneSelectorId(cxt)
|
|
110
|
-
testSelectors(cxt,
|
|
106
|
+
function ViewStreamSelector(cxt, sel) {
|
|
107
|
+
cxt = typeof (cxt) === 'string' ? cxt : generateSpyneSelectorId(cxt)
|
|
108
|
+
testSelectors(cxt, sel, false)
|
|
111
109
|
|
|
112
|
-
function selector(
|
|
113
|
-
return ViewStreamSelector(cxt,
|
|
110
|
+
function selector(sel) {
|
|
111
|
+
return ViewStreamSelector(cxt, sel)
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
|
|
117
114
|
/**
|
|
118
115
|
* Convenience method to map through a NodeList.
|
|
119
116
|
*
|
|
120
117
|
* @param {Function} fn
|
|
121
118
|
* @returns An array of elements
|
|
122
119
|
*/
|
|
123
|
-
selector.map = (fn)=> Array.from(getNodeListArray(cxt,
|
|
120
|
+
selector.map = (fn) => Array.from(getNodeListArray(cxt, sel)).map(fn)
|
|
124
121
|
|
|
125
122
|
/**
|
|
126
123
|
* Convenience method to iterate through a NodeList
|
|
@@ -128,10 +125,9 @@ function ViewStreamSelector(cxt, str) {
|
|
|
128
125
|
* @param {Function} fn
|
|
129
126
|
* @returns An array of elements
|
|
130
127
|
*/
|
|
131
|
-
selector.forEach = (fn)=> Array.from(getNodeListArray(cxt,
|
|
132
|
-
|
|
128
|
+
selector.forEach = (fn) => Array.from(getNodeListArray(cxt, sel)).map(fn)
|
|
133
129
|
|
|
134
|
-
selector.getNodeListArray = () => getNodeListArray(cxt,
|
|
130
|
+
selector.getNodeListArray = () => getNodeListArray(cxt, sel)
|
|
135
131
|
|
|
136
132
|
/**
|
|
137
133
|
*
|
|
@@ -143,11 +139,11 @@ function ViewStreamSelector(cxt, str) {
|
|
|
143
139
|
*
|
|
144
140
|
**/
|
|
145
141
|
selector.addClass = (c) => {
|
|
146
|
-
|
|
147
|
-
const addClass = item => item.classList.add(c)
|
|
148
|
-
arr.forEach(addClass)
|
|
149
|
-
return this
|
|
150
|
-
}
|
|
142
|
+
const arr = getNodeListArray(cxt, sel)
|
|
143
|
+
const addClass = item => item.classList.add(c)
|
|
144
|
+
arr.forEach(addClass)
|
|
145
|
+
return this
|
|
146
|
+
}
|
|
151
147
|
|
|
152
148
|
/**
|
|
153
149
|
*
|
|
@@ -155,13 +151,13 @@ function ViewStreamSelector(cxt, str) {
|
|
|
155
151
|
* @desc Removes the class to the Element or to the NodeList.
|
|
156
152
|
*/
|
|
157
153
|
selector.removeClass = (c) => {
|
|
158
|
-
|
|
154
|
+
const arr = getNodeListArray(cxt, sel)
|
|
159
155
|
const removeClass = item => {
|
|
160
|
-
item.classList.remove(c)
|
|
161
|
-
}
|
|
162
|
-
arr.forEach(removeClass)
|
|
163
|
-
return this
|
|
164
|
-
}
|
|
156
|
+
item.classList.remove(c)
|
|
157
|
+
}
|
|
158
|
+
arr.forEach(removeClass)
|
|
159
|
+
return this
|
|
160
|
+
}
|
|
165
161
|
|
|
166
162
|
/**
|
|
167
163
|
*
|
|
@@ -169,29 +165,28 @@ function ViewStreamSelector(cxt, str) {
|
|
|
169
165
|
* @desc Sets the class to equal exactly the class string.
|
|
170
166
|
*/
|
|
171
167
|
selector.setClass = (c) => {
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
const arr = getNodeListArray(cxt, sel)
|
|
169
|
+
/**
|
|
174
170
|
* NON IE CLEANER SOLUTION
|
|
175
171
|
* const removeClass = item => item.classList = c;
|
|
176
172
|
* arr.forEach(removeClass);
|
|
177
173
|
*/
|
|
178
174
|
|
|
179
175
|
const setTheClass = item => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const remover = s => item.classList.remove(s)
|
|
183
|
-
const adder =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
arr.forEach(setTheClass)
|
|
188
|
-
return this
|
|
189
|
-
}
|
|
176
|
+
const removeClassStrArr = compose(reject(isEmpty), split(' '))(item.className)
|
|
177
|
+
const classStrArr = c.split(' ')
|
|
178
|
+
const remover = s => item.classList.remove(s)
|
|
179
|
+
const adder = sel => item.classList.add(sel)
|
|
180
|
+
removeClassStrArr.forEach(remover)
|
|
181
|
+
classStrArr.forEach(adder)
|
|
182
|
+
}
|
|
183
|
+
arr.forEach(setTheClass)
|
|
184
|
+
return this
|
|
185
|
+
}
|
|
190
186
|
|
|
191
187
|
selector.unmount = () => {
|
|
192
|
-
//console.log('unmounting selector ', this);
|
|
193
|
-
}
|
|
194
|
-
|
|
188
|
+
// console.log('unmounting selector ', this);
|
|
189
|
+
}
|
|
195
190
|
|
|
196
191
|
/**
|
|
197
192
|
*
|
|
@@ -204,69 +199,72 @@ function ViewStreamSelector(cxt, str) {
|
|
|
204
199
|
*
|
|
205
200
|
*/
|
|
206
201
|
selector.toggleClass = (c, bool) => {
|
|
207
|
-
|
|
202
|
+
const arr = getNodeListArray(cxt, sel)
|
|
208
203
|
const toggleClass = item => {
|
|
209
|
-
bool = bool !== undefined ? bool : !item.classList.contains(c)
|
|
210
|
-
bool ?
|
|
211
|
-
}
|
|
212
|
-
arr.forEach(toggleClass)
|
|
213
|
-
return this
|
|
214
|
-
}
|
|
215
|
-
|
|
204
|
+
bool = bool !== undefined ? bool : !item.classList.contains(c)
|
|
205
|
+
bool ? item.classList.add(c) : item.classList.remove(c)
|
|
206
|
+
}
|
|
207
|
+
arr.forEach(toggleClass)
|
|
208
|
+
return this
|
|
209
|
+
}
|
|
216
210
|
|
|
217
211
|
selector.toggle = (c, bool) => {
|
|
218
|
-
selector.toggleClass(c, bool)
|
|
219
|
-
return this
|
|
220
|
-
}
|
|
221
|
-
|
|
212
|
+
selector.toggleClass(c, bool)
|
|
213
|
+
return this
|
|
214
|
+
}
|
|
222
215
|
|
|
223
216
|
/**
|
|
224
217
|
* Attaches html to the Selector's element
|
|
225
218
|
* @param htmlElement
|
|
226
219
|
*/
|
|
227
|
-
selector.appendChild=(htmlElement)=>{
|
|
228
|
-
if (selector.el.length!==0) {
|
|
229
|
-
selector.el.appendChild(htmlElement)
|
|
230
|
-
} else{
|
|
231
|
-
console.warn(`Spyne Warning: The selector, ${
|
|
220
|
+
selector.appendChild = (htmlElement) => {
|
|
221
|
+
if (selector.el.length !== 0) {
|
|
222
|
+
selector.el.appendChild(htmlElement)
|
|
223
|
+
} else {
|
|
224
|
+
console.warn(`Spyne Warning: The selector, ${sel} does not appear to be valid!`)
|
|
232
225
|
}
|
|
233
226
|
|
|
234
|
-
return selector.el
|
|
235
|
-
}
|
|
227
|
+
return selector.el
|
|
228
|
+
}
|
|
236
229
|
|
|
237
230
|
/**
|
|
238
231
|
*
|
|
239
232
|
* Adds class with a delay of 1ms to allow css to register a transition.
|
|
240
233
|
* @param c
|
|
241
234
|
*/
|
|
242
|
-
selector.addAnimClass = (c)=>{
|
|
243
|
-
const delayAddClass = ()=>{
|
|
244
|
-
|
|
245
|
-
const addClass = item =>
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
235
|
+
selector.addAnimClass = (c) => {
|
|
236
|
+
const delayAddClass = () => {
|
|
237
|
+
const arr = getNodeListArray(cxt, sel)
|
|
238
|
+
const addClass = item => {
|
|
239
|
+
try {
|
|
240
|
+
item.classList.add(c)
|
|
241
|
+
} catch (e) {
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
arr.forEach(addClass)
|
|
245
|
+
}
|
|
246
|
+
requestAnimationFrame(delayAddClass)
|
|
247
|
+
// window.setTimeout(delayAddClass, 1);
|
|
248
|
+
}
|
|
251
249
|
|
|
252
250
|
/**
|
|
253
251
|
*
|
|
254
252
|
* @param {String} c
|
|
255
|
-
* @param {String|HTMLElement}
|
|
253
|
+
* @param {String|HTMLElement} elSel The selector for the element.
|
|
256
254
|
* @desc Sets the class active HTMLElement from a NodeList.
|
|
257
255
|
*/
|
|
258
|
-
selector.setActiveItem = (c,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const toggleBool = item => item.isEqualNode(currentEl) ? item.classList.add(c) : item.classList.remove(c)
|
|
262
|
-
if (isNodeElement(currentEl)===true) {
|
|
263
|
-
arr.forEach(toggleBool)
|
|
264
|
-
} else if (isDevMode()===true){
|
|
265
|
-
//console.log("SEL IS ",
|
|
266
|
-
console.warn(`Spyne Warning: The selector, ${
|
|
256
|
+
selector.setActiveItem = (c, elSel) => {
|
|
257
|
+
const arr = getNodeListArray(cxt, sel)
|
|
258
|
+
const currentEl = typeof (elSel) === 'string' ? getElOrList(cxt, elSel) : elSel
|
|
259
|
+
const toggleBool = item => item.isEqualNode(currentEl) ? item.classList.add(c) : item.classList.remove(c)
|
|
260
|
+
if (isNodeElement(currentEl) === true) {
|
|
261
|
+
arr.forEach(toggleBool)
|
|
262
|
+
} else if (isDevMode() === true) {
|
|
263
|
+
// console.log("SEL IS ",elSel,c);
|
|
264
|
+
console.warn(`Spyne Warning: The selector, ${elSel}, does not appear to be a valid item in setActiveItem: ${c}`)
|
|
267
265
|
}
|
|
268
|
-
return this
|
|
269
|
-
}
|
|
266
|
+
return this
|
|
267
|
+
}
|
|
270
268
|
|
|
271
269
|
/**
|
|
272
270
|
*
|
|
@@ -279,7 +277,6 @@ function ViewStreamSelector(cxt, str) {
|
|
|
279
277
|
* The a single element or a NodeList from the selector
|
|
280
278
|
*/
|
|
281
279
|
|
|
282
|
-
|
|
283
280
|
/**
|
|
284
281
|
*
|
|
285
282
|
* @function length
|
|
@@ -302,32 +299,29 @@ function ViewStreamSelector(cxt, str) {
|
|
|
302
299
|
* Boolean
|
|
303
300
|
*/
|
|
304
301
|
|
|
305
|
-
|
|
306
|
-
Object.defineProperty(selector, '
|
|
307
|
-
Object.defineProperty(selector, '
|
|
308
|
-
Object.defineProperty(selector, '
|
|
309
|
-
Object.defineProperty(selector, '
|
|
310
|
-
Object.defineProperty(selector, '
|
|
311
|
-
Object.defineProperty(selector, '
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
302
|
+
Object.defineProperty(selector, 'el', { get: () => getElOrList(cxt, sel, true) })
|
|
303
|
+
Object.defineProperty(selector, 'els', { get: () => getNodeListArray(cxt, sel) })
|
|
304
|
+
Object.defineProperty(selector, 'len', { get: () => getNodeListArray(cxt, sel, false).length })
|
|
305
|
+
Object.defineProperty(selector, 'exists', { get: () => getNodeListArray(cxt, sel, false).length >= 1 })
|
|
306
|
+
Object.defineProperty(selector, 'exist', { get: () => getNodeListArray(cxt, sel, false).length >= 1 })
|
|
307
|
+
Object.defineProperty(selector, 'nodeList', { get: () => getNodeListArray(cxt, sel) })
|
|
308
|
+
Object.defineProperty(selector, 'arr', {
|
|
309
|
+
get: () => {
|
|
310
|
+
const el = getElOrList(cxt, sel, true)
|
|
311
|
+
if (el === undefined) {
|
|
312
|
+
return []
|
|
313
|
+
} else if (el.length === undefined) {
|
|
314
|
+
return [el]
|
|
315
|
+
} else {
|
|
316
|
+
return Array.from(el)
|
|
317
|
+
}
|
|
320
318
|
}
|
|
319
|
+
})
|
|
321
320
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Object.defineProperty(selector, 'inline', {set: (val) => setInlineCss(val, cxt, str)});
|
|
327
|
-
Object.defineProperty(selector, 'inlineCss', {set: (val) => setInlineCss(val, cxt, str)});
|
|
328
|
-
|
|
329
|
-
return selector;
|
|
321
|
+
Object.defineProperty(selector, 'inline', { set: (val) => setInlineCss(val, cxt, sel), get: () => selector })
|
|
322
|
+
Object.defineProperty(selector, 'inlineCss', { set: (val) => setInlineCss(val, cxt, sel), get: () => selector })
|
|
330
323
|
|
|
324
|
+
return selector
|
|
331
325
|
}
|
|
332
326
|
|
|
333
|
-
export {ViewStreamSelector}
|
|
327
|
+
export { ViewStreamSelector }
|