SLING-9406 - Add bundled script support to the servlets resolver
* look at the parent of the caller when looking up childs
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
index 01d5521..17c034c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
@@ -51,6 +51,9 @@
public static Resource getScriptResource(Resource caller, String path, Bindings bindings) {
Resource scriptResource = caller.getChild(path);
if (scriptResource == null) {
+ scriptResource = caller.getParent().getChild(path);
+ }
+ if (scriptResource == null) {
Resource componentCaller = ResourceResolution
.getResourceForRequest(caller.getResourceResolver(), (SlingHttpServletRequest) bindings.get(SlingBindings.REQUEST));
if (isResourceOverlay(caller, componentCaller)) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
index 44fc612..4db41ae 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
@@ -91,9 +91,6 @@
if (resource != null) {
String type = resource.getResourceType();
caller = scriptingResourceResolver.getResource(type);
- if (caller != null) {
- scriptResource = Utils.getScriptResource(caller, dependency, bindings);
- }
}
}
if (caller != null) {