File tree Expand file tree Collapse file tree 3 files changed +12
-34
lines changed
app/code/Magento/Ui/view/base/templates/form Expand file tree Collapse file tree 3 files changed +12
-34
lines changed Original file line number Diff line number Diff line change 6
6
/**
7
7
* @var \Magento\Ui\Component\Form $block
8
8
*/
9
+ $ formConfig = $ block ->getRenderContext ()->getConfigBuilder ()->toJsonNew ($ block ->getRenderContext ()->getStorage ());
9
10
?>
10
11
<script type="text/x-magento-init">
11
12
{
12
13
"*": {
13
- "Magento_Ui/js/core/app": <?php echo $ block -> getRenderContext ()-> getConfigBuilder ()-> toJsonNew ( $ block -> getRenderContext ()-> getStorage ()) ; ?>
14
+ "Magento_Ui/js/core/app": <?php echo $ formConfig ; ?>
14
15
}
15
16
}
16
17
</script>
Original file line number Diff line number Diff line change @@ -33,19 +33,6 @@ define([
33
33
} ) ;
34
34
}
35
35
36
- /**
37
- * Searches for elements with a 'data-mage-init' attribute.
38
- *
39
- * @returns {Array } An array of elements with 'data-mage-init' attribute.
40
- */
41
- function getElems ( ) {
42
- var elems ;
43
-
44
- elems = document . querySelectorAll ( nodeSelector ) ;
45
-
46
- return _ . toArray ( elems ) ;
47
- }
48
-
49
36
/**
50
37
* Parses elements 'data-mage-init' attribute as a valid JSON data.
51
38
* Note: data-mage-init attribute will be removed.
@@ -72,11 +59,12 @@ define([
72
59
* data-mage-init='{"path/to/component": {"foo": "bar"}}'
73
60
*/
74
61
apply : function ( ) {
75
- var virtual = processScripts ( ) ;
62
+ var virtuals = processScripts ( ) ,
63
+ nodes = document . querySelectorAll ( nodeSelector ) ;
76
64
77
- getElems ( )
65
+ _ . toArray ( nodes )
78
66
. map ( getData )
79
- . concat ( virtual )
67
+ . concat ( virtuals )
80
68
. forEach ( function ( item ) {
81
69
_ . each ( item . data , init . bind ( null , item . el ) ) ;
82
70
} ) ;
Original file line number Diff line number Diff line change @@ -10,15 +10,15 @@ define([
10
10
11
11
var scriptSelector = 'script[type="text/x-magento-init"]' ,
12
12
dataAttr = 'data-mage-init' ,
13
- virtual = [ ] ;
13
+ virtuals = [ ] ;
14
14
15
15
/**
16
16
* Adds components to the virtula list.
17
17
*
18
18
* @param {Object } components
19
19
*/
20
20
function addVirtual ( components ) {
21
- virtual . push ( {
21
+ virtuals . push ( {
22
22
el : false ,
23
23
data : components
24
24
} ) ;
@@ -63,19 +63,6 @@ define([
63
63
_ . toArray ( elems ) . forEach ( iterator ) ;
64
64
}
65
65
66
- /**
67
- * Searches for script tags whith a 'text/x-magento-init' type.
68
- *
69
- * @returns {Array } An array of elements script nodes.
70
- */
71
- function getNodes ( ) {
72
- var elems ;
73
-
74
- elems = document . querySelectorAll ( scriptSelector ) ;
75
-
76
- return _ . toArray ( elems ) ;
77
- }
78
-
79
66
/**
80
67
* Parses content of a provided script node.
81
68
* Note: node will be removed from DOM.
@@ -115,12 +102,14 @@ define([
115
102
* }
116
103
*/
117
104
return function ( ) {
118
- getNodes ( )
105
+ var nodes = document . querySelectorAll ( scriptSelector ) ;
106
+
107
+ _ . toArray ( nodes )
119
108
. map ( getNodeData )
120
109
. forEach ( function ( item ) {
121
110
_ . each ( item , processElems ) ;
122
111
} ) ;
123
112
124
- return virtual . splice ( 0 , virtual . length ) ;
113
+ return virtuals . splice ( 0 , virtuals . length ) ;
125
114
} ;
126
115
} ) ;
You can’t perform that action at this time.
0 commit comments