@@ -288,16 +288,17 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
288288 final Map <String , Function > ctorPrototypesPerJSName = new HashMap <>();
289289 for (final ClassConfiguration config : jsConfig .getAll ()) {
290290 final String jsClassName = config .getClassName ();
291+ Scriptable prototype = prototypesPerJSName .get (jsClassName );
292+ final String extendedClassName =
293+ StringUtils .isEmpty (config .getExtendedClassName ()) ? null : config .getExtendedClassName ();
291294
292295 // setup the prototypes
293296 if (config == scopeConfig ) {
294- final Scriptable prototype = prototypesPerJSName .get (jsClassName );
295- if (StringUtils .isEmpty (config .getExtendedClassName ())) {
297+ if (extendedClassName == null ) {
296298 prototype .setPrototype (objectPrototype );
297299 }
298300 else {
299- final Scriptable parentPrototype = prototypesPerJSName .get (config .getExtendedClassName ());
300- prototype .setPrototype (parentPrototype );
301+ prototype .setPrototype (prototypesPerJSName .get (extendedClassName ));
301302 }
302303 }
303304 else {
@@ -315,27 +316,24 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
315316 }
316317 prototypes .put (config .getHostClass (), classPrototype );
317318 prototypesPerJSName .put (jsClassName , classPrototype );
319+ prototype = classPrototype ;
318320
319- if (StringUtils . isEmpty ( config . getExtendedClassName ()) ) {
321+ if (extendedClassName == null ) {
320322 classPrototype .setPrototype (objectPrototype );
321323 }
322324 else {
323- final Scriptable parentPrototype = prototypesPerJSName .get (config .getExtendedClassName ());
324- classPrototype .setPrototype (parentPrototype );
325+ classPrototype .setPrototype (prototypesPerJSName .get (extendedClassName ));
325326 }
326327 }
327328
328329 // setup constructors
329- final Scriptable prototype = prototypesPerJSName .get (jsClassName );
330-
331330 if (config == scopeConfig ) {
332331 addAsConstructorAndAlias (scopeContructorFunctionObject , jsScope , prototype , config );
333332 configureConstantsStaticPropertiesAndStaticFunctions (config , scopeContructorFunctionObject );
334333
335334 // adjust prototype if needed
336- if (!StringUtils .isEmpty (config .getExtendedClassName ())) {
337- final Scriptable parentPrototype = ctorPrototypesPerJSName .get (config .getExtendedClassName ());
338- scopeContructorFunctionObject .setPrototype (parentPrototype );
335+ if (extendedClassName != null ) {
336+ scopeContructorFunctionObject .setPrototype (ctorPrototypesPerJSName .get (extendedClassName ));
339337 }
340338 }
341339 else {
@@ -355,9 +353,8 @@ public static void configureScope(final HtmlUnitScriptable jsScope,
355353 configureConstantsStaticPropertiesAndStaticFunctions (config , function );
356354
357355 // adjust prototype if needed
358- if (!StringUtils .isEmpty (config .getExtendedClassName ())) {
359- final Scriptable parentPrototype = ctorPrototypesPerJSName .get (config .getExtendedClassName ());
360- function .setPrototype (parentPrototype );
356+ if (extendedClassName != null ) {
357+ function .setPrototype (ctorPrototypesPerJSName .get (extendedClassName ));
361358 }
362359 }
363360 }
0 commit comments