Skip to content

Commit c8da110

Browse files
author
Anu1601CS
committed
await
1 parent 5bf5f44 commit c8da110

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

build/webcomponents/js/editor-codemirror/editor-codemirror.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ customElements.define('joomla-editor-codemirror', class extends HTMLElement {
115115
this.instance = window.CodeMirror.fromTextArea(element, this.options);
116116
}
117117

118-
static rafAsync() {
118+
rafAsync() {
119119
return new Promise(resolve => requestAnimationFrame(resolve));
120120
}
121121

122122
async checkElement(string1, string2) {
123123
if (string2) {
124124
while (typeof window[string1][string2] !== 'function') {
125-
this.rafAsync();
125+
await this.rafAsync();
126126
}
127127
} else {
128128
while (typeof window[string1] !== 'function') {
129-
this.rafAsync();
129+
await this.rafAsync();
130130
}
131131
}
132132

media/system/webcomponents/js/joomla-editor-codemirror-es5.js

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ customElements.define('joomla-editor-codemirror', function (_HTMLElement) {
132132
value: function refresh(element) {
133133
this.instance = window.CodeMirror.fromTextArea(element, this.options);
134134
}
135+
}, {
136+
key: 'rafAsync',
137+
value: function rafAsync() {
138+
return new Promise(function (resolve) {
139+
return requestAnimationFrame(resolve);
140+
});
141+
}
135142
}, {
136143
key: 'checkElement',
137144
value: function () {
@@ -140,19 +147,45 @@ customElements.define('joomla-editor-codemirror', function (_HTMLElement) {
140147
while (1) {
141148
switch (_context.prev = _context.next) {
142149
case 0:
143-
if (string2) {
144-
while (typeof window[string1][string2] !== 'function') {
145-
this.rafAsync();
146-
}
147-
} else {
148-
while (typeof window[string1] !== 'function') {
149-
this.rafAsync();
150-
}
150+
if (!string2) {
151+
_context.next = 8;
152+
break;
153+
}
154+
155+
case 1:
156+
if (!(typeof window[string1][string2] !== 'function')) {
157+
_context.next = 6;
158+
break;
151159
}
152160

161+
_context.next = 4;
162+
return this.rafAsync();
163+
164+
case 4:
165+
_context.next = 1;
166+
break;
167+
168+
case 6:
169+
_context.next = 13;
170+
break;
171+
172+
case 8:
173+
if (!(typeof window[string1] !== 'function')) {
174+
_context.next = 13;
175+
break;
176+
}
177+
178+
_context.next = 11;
179+
return this.rafAsync();
180+
181+
case 11:
182+
_context.next = 8;
183+
break;
184+
185+
case 13:
153186
return _context.abrupt('return', true);
154187

155-
case 2:
188+
case 14:
156189
case 'end':
157190
return _context.stop();
158191
}
@@ -186,13 +219,6 @@ customElements.define('joomla-editor-codemirror', function (_HTMLElement) {
186219
this.setAttribute('options', value);
187220
}
188221
}], [{
189-
key: 'rafAsync',
190-
value: function rafAsync() {
191-
return new Promise(function (resolve) {
192-
return requestAnimationFrame(resolve);
193-
});
194-
}
195-
}, {
196222
key: 'makeMarker',
197223
value: function makeMarker() {
198224
var marker = document.createElement('div');

media/system/webcomponents/js/joomla-editor-codemirror-es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

media/system/webcomponents/js/joomla-editor-codemirror.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ customElements.define('joomla-editor-codemirror', class extends HTMLElement {
115115
this.instance = window.CodeMirror.fromTextArea(element, this.options);
116116
}
117117

118-
static rafAsync() {
118+
rafAsync() {
119119
return new Promise(resolve => requestAnimationFrame(resolve));
120120
}
121121

122122
async checkElement(string1, string2) {
123123
if (string2) {
124124
while (typeof window[string1][string2] !== 'function') {
125-
this.rafAsync();
125+
await this.rafAsync();
126126
}
127127
} else {
128128
while (typeof window[string1] !== 'function') {
129-
this.rafAsync();
129+
await this.rafAsync();
130130
}
131131
}
132132

media/system/webcomponents/js/joomla-editor-codemirror.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)