Skip to content

Commit 7f90a4f

Browse files
committed
scope handling (wip)
1 parent 3d03e03 commit 7f90a4f

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

src/main/java/org/htmlunit/javascript/host/Element.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ public Attr setAttributeNode(final Attr newAtt) {
514514
@JsxFunction
515515
public NodeList querySelectorAll(final String selectors) {
516516
try {
517-
return NodeList.staticNodeList(this, getDomNodeOrDie().querySelectorAll(selectors));
517+
return NodeList.staticNodeList(getParentScope(), getDomNodeOrDie().querySelectorAll(selectors));
518518
}
519519
catch (final CSSException e) {
520520
throw JavaScriptEngine.asJavaScriptException(

src/main/java/org/htmlunit/javascript/host/dom/Document.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ public Node querySelector(final String selectors) {
995995
@JsxFunction
996996
public NodeList querySelectorAll(final String selectors) {
997997
try {
998-
return NodeList.staticNodeList(this, getDomNodeOrDie().querySelectorAll(selectors));
998+
return NodeList.staticNodeList(getParentScope(), getDomNodeOrDie().querySelectorAll(selectors));
999999
}
10001000
catch (final CSSException e) {
10011001
throw JavaScriptEngine.asJavaScriptException(

src/main/java/org/htmlunit/javascript/host/dom/DocumentFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public static void moveBefore(final Context context, final Scriptable scope,
130130
@JsxFunction
131131
public NodeList querySelectorAll(final String selectors) {
132132
try {
133-
return NodeList.staticNodeList(this, getDomNodeOrDie().querySelectorAll(selectors));
133+
return NodeList.staticNodeList(getParentScope(), getDomNodeOrDie().querySelectorAll(selectors));
134134
}
135135
catch (final CSSException e) {
136136
throw JavaScriptEngine.reportRuntimeError("An invalid or illegal selector was specified (selector: '"

src/main/java/org/htmlunit/javascript/host/dom/NodeList.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
import org.htmlunit.corejs.javascript.ContextAction;
2424
import org.htmlunit.corejs.javascript.Function;
2525
import org.htmlunit.corejs.javascript.Scriptable;
26-
import org.htmlunit.corejs.javascript.ScriptableObject;
2726
import org.htmlunit.html.DomNode;
2827
import org.htmlunit.javascript.HtmlUnitContextFactory;
29-
import org.htmlunit.javascript.HtmlUnitScriptable;
3028
import org.htmlunit.javascript.JavaScriptEngine;
3129
import org.htmlunit.javascript.configuration.JsxClass;
3230
import org.htmlunit.javascript.configuration.JsxConstructor;
@@ -90,7 +88,7 @@ public NodeList(final DomNode domNode, final List<DomNode> initialElements) {
9088
* Creates an instance.
9189
* @param parentScope the parent scope
9290
*/
93-
NodeList(final ScriptableObject parentScope) {
91+
NodeList(final Scriptable parentScope) {
9492
super();
9593
setParentScope(parentScope);
9694
setPrototype(getPrototype(getClass()));
@@ -104,7 +102,7 @@ public NodeList(final DomNode domNode, final List<DomNode> initialElements) {
104102
* @param elements the elements
105103
* @return an empty collection
106104
*/
107-
public static NodeList staticNodeList(final HtmlUnitScriptable parentScope, final List<DomNode> elements) {
105+
public static NodeList staticNodeList(final Scriptable parentScope, final List<DomNode> elements) {
108106
return new NodeList(parentScope) {
109107
@Override
110108
public List<DomNode> getElements() {

src/main/java/org/htmlunit/javascript/host/html/HTMLDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public NodeList getElementsByName(final String elementName) {
571571
if ("null".equals(elementName)
572572
|| (elementName.isEmpty()
573573
&& getBrowserVersion().hasFeature(HTMLDOCUMENT_ELEMENTS_BY_NAME_EMPTY))) {
574-
return NodeList.staticNodeList(getWindow(), new ArrayList<>());
574+
return NodeList.staticNodeList(getParentScope(), new ArrayList<>());
575575
}
576576

577577
final HtmlPage page = getPage();

0 commit comments

Comments
 (0)