Skip to content

NPE in ComputedCSSStyleDeclaration.getLeft #488

@gaellalire

Description

@gaellalire
Caused by: java.lang.NullPointerException: null
	at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getLeft(ComputedCSSStyleDeclaration.java:1580)
	at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.getOffsetLeft(HTMLElement.java:1393)

Issue is still there in 2.62.0.

I tested if parent is null to workaround the issue, worked for me but maybe not the best fix.

			final HTMLElement parent = (HTMLElement) getElement().getParentElement();
			if (parent != null) {
				final ComputedCSSStyleDeclaration style = parent.getWindow().getComputedStyle(parent, null);
				left = pixelValue(style.getLeftWithInheritance());
			} else {
				left = 0;
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions