|
4 | 4 |
|
5 | 5 | 'use strict'; |
6 | 6 |
|
7 | | -(function() { |
| 7 | +(function () { |
8 | 8 | var Fixture = null; |
9 | 9 | var output = document.getElementById('output'); |
10 | 10 | var status = document.getElementById('status'); |
|
60 | 60 | setStatus('Generating markup'); |
61 | 61 |
|
62 | 62 | return Promise.resolve() |
63 | | - .then(function() { |
| 63 | + .then(function () { |
64 | 64 | const element = createElement(Fixture); |
65 | 65 |
|
66 | 66 | // Server rendering moved to a separate package along with ReactDOM |
|
80 | 80 | } |
81 | 81 |
|
82 | 82 | // Finally, React 0.4 and lower emits markup in a callback |
83 | | - return new Promise(function(resolve) { |
| 83 | + return new Promise(function (resolve) { |
84 | 84 | React.renderComponentToString(element, resolve); |
85 | 85 | }); |
86 | 86 | }) |
87 | | - .then(function(string) { |
| 87 | + .then(function (string) { |
88 | 88 | output.innerHTML = string; |
89 | 89 | setStatus('Markup only (No React)'); |
90 | 90 | }) |
|
124 | 124 | } |
125 | 125 |
|
126 | 126 | function loadScript(src) { |
127 | | - return new Promise(function(resolve, reject) { |
| 127 | + return new Promise(function (resolve, reject) { |
128 | 128 | var script = document.createElement('script'); |
129 | 129 | script.async = true; |
130 | 130 | script.src = src; |
131 | 131 |
|
132 | 132 | script.onload = resolve; |
133 | | - script.onerror = function(error) { |
| 133 | + script.onerror = function (error) { |
134 | 134 | reject(new Error('Unable to load ' + src)); |
135 | 135 | }; |
136 | 136 |
|
|
145 | 145 | setStatus('Failed'); |
146 | 146 | output.innerHTML = 'Please name your root component "Fixture"'; |
147 | 147 | } else { |
148 | | - prerender().then(function() { |
| 148 | + prerender().then(function () { |
149 | 149 | if (getBooleanQueryParam('hydrate')) { |
150 | 150 | render(); |
151 | 151 | } |
|
161 | 161 |
|
162 | 162 | window.onerror = handleError; |
163 | 163 |
|
164 | | - reload.onclick = function() { |
| 164 | + reload.onclick = function () { |
165 | 165 | window.location.reload(); |
166 | 166 | }; |
167 | 167 |
|
168 | 168 | hydrate.onclick = render; |
169 | 169 |
|
170 | 170 | loadScript(getQueryParam('reactPath')) |
171 | | - .then(function() { |
| 171 | + .then(function () { |
172 | 172 | if (needsReactDOM) { |
173 | 173 | return Promise.all([ |
174 | 174 | loadScript(getQueryParam('reactDOMPath')), |
175 | 175 | loadScript(getQueryParam('reactDOMServerPath')), |
176 | 176 | ]); |
177 | 177 | } |
178 | 178 | }) |
179 | | - .then(function() { |
| 179 | + .then(function () { |
180 | 180 | if (failed) { |
181 | 181 | return; |
182 | 182 | } |
183 | 183 |
|
184 | | - window.addEventListener('message', function(event) { |
| 184 | + window.addEventListener('message', function (event) { |
185 | 185 | var data = JSON.parse(event.data); |
186 | 186 |
|
187 | 187 | switch (data.type) { |
|
0 commit comments