1
1
'use strict' ;
2
2
const WeakMap = ( m => m . __esModule ? /* istanbul ignore next */ m . default : /* istanbul ignore next */ m ) ( require ( '@ungap/weakmap' ) ) ;
3
- const unique = ( m => m . __esModule ? /* istanbul ignore next */ m . default : /* istanbul ignore next */ m ) ( require ( '@ungap/template-literal' ) ) ;
4
3
const trim = ( m => m . __esModule ? /* istanbul ignore next */ m . default : /* istanbul ignore next */ m ) ( require ( '@ungap/trim' ) ) ;
5
4
6
5
const { ELEMENT_NODE } = require ( '../shared/constants.js' ) ;
7
6
const Wire = ( m => m . __esModule ? /* istanbul ignore next */ m . default : /* istanbul ignore next */ m ) ( require ( '../classes/Wire.js' ) ) ;
8
7
9
8
const { Tagger} = require ( '../objects/Updates.js' ) ;
9
+ const { reArguments} = require ( '../shared/utils.js' ) ;
10
10
11
11
// all wires used per each context
12
12
const wires = new WeakMap ;
@@ -17,7 +17,7 @@ const wires = new WeakMap;
17
17
// This provides the ability to have a unique DOM structure
18
18
// related to a unique JS object through a reusable template literal.
19
19
// A wire can specify a type, as svg or html, and also an id
20
- // via html:id or :id convention. Such :id allows same JS objects
20
+ // via the html:id or :id convention. Such :id allows same JS objects
21
21
// to be associated to different DOM structures accordingly with
22
22
// the used template literal without losing previously rendered parts.
23
23
const wire = ( obj , type ) => obj == null ?
@@ -32,22 +32,22 @@ const wire = (obj, type) => obj == null ?
32
32
// in charge of updating its content like a bound element would do.
33
33
const content = type => {
34
34
let wire , tagger , template ;
35
- return function ( statics ) {
36
- statics = unique ( statics ) ;
37
- if ( template !== statics ) {
38
- template = statics ;
35
+ return function ( ) {
36
+ const args = reArguments . apply ( null , arguments ) ;
37
+ if ( template !== args [ 0 ] ) {
38
+ template = args [ 0 ] ;
39
39
tagger = new Tagger ( type ) ;
40
- wire = wireContent ( tagger . apply ( tagger , arguments ) ) ;
40
+ wire = wireContent ( tagger . apply ( tagger , args ) ) ;
41
41
} else {
42
- tagger . apply ( tagger , arguments ) ;
42
+ tagger . apply ( tagger , args ) ;
43
43
}
44
44
return wire ;
45
45
} ;
46
46
} ;
47
47
48
48
// wires are weakly created through objects.
49
49
// Each object can have multiple wires associated
50
- // and this is thanks to the type + :id feature.
50
+ // thanks to the type + :id feature.
51
51
const weakly = ( obj , type ) => {
52
52
const i = type . indexOf ( ':' ) ;
53
53
let wire = wires . get ( obj ) ;
@@ -61,7 +61,7 @@ const weakly = (obj, type) => {
61
61
return wire [ id ] || ( wire [ id ] = content ( type ) ) ;
62
62
} ;
63
63
64
- // a document fragment loses its nodes as soon
64
+ // A document fragment loses its nodes as soon
65
65
// as it's appended into another node.
66
66
// This would easily lose wired content
67
67
// so that on a second render call, the parent
0 commit comments