Skip to content

Commit 31d5937

Browse files
committed
refactor the loop a bit more
1 parent 1783673 commit 31d5937

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/main/java/org/htmlunit/javascript/JavaScriptEngine.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
300300
else {
301301
prototype.setPrototype(prototypesPerJSName.get(extendedClassName));
302302
}
303+
304+
// setup constructors
305+
addAsConstructorAndAlias(scopeContructorFunctionObject, jsScope, prototype, config);
306+
configureConstantsStaticPropertiesAndStaticFunctions(config, scopeContructorFunctionObject);
307+
308+
// adjust prototype if needed
309+
if (extendedClassName != null) {
310+
scopeContructorFunctionObject.setPrototype(ctorPrototypesPerJSName.get(extendedClassName));
311+
}
303312
}
304313
else {
305314
final HtmlUnitScriptable classPrototype = configureClass(config, jsScope);
@@ -324,21 +333,10 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
324333
else {
325334
classPrototype.setPrototype(prototypesPerJSName.get(extendedClassName));
326335
}
327-
}
328336

329-
// setup constructors
330-
if (config == scopeConfig) {
331-
addAsConstructorAndAlias(scopeContructorFunctionObject, jsScope, prototype, config);
332-
configureConstantsStaticPropertiesAndStaticFunctions(config, scopeContructorFunctionObject);
333-
334-
// adjust prototype if needed
335-
if (extendedClassName != null) {
336-
scopeContructorFunctionObject.setPrototype(ctorPrototypesPerJSName.get(extendedClassName));
337-
}
338-
}
339-
else {
340-
final Map.Entry<String, Member> jsConstructor = config.getJsConstructor();
337+
// setup constructors
341338
if (prototype != null && config.isJsObject()) {
339+
final Map.Entry<String, Member> jsConstructor = config.getJsConstructor();
342340
if (jsConstructor == null) {
343341
final ScriptableObject constructor = config.getHostClass().getDeclaredConstructor().newInstance();
344342
((HtmlUnitScriptable) constructor).setClassName(jsClassName);

0 commit comments

Comments
 (0)