File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
src/grails/grails-app/taglib
test/groovy/org/codehaus/groovy/grails/web/taglib Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class JavascriptTagLib {
5959 **/
6060 def javascript = { attrs , body ->
6161 setUpRequestAttributes();
62- def requestPluginContext = request[CONTROLLER ]. pluginContextPath
62+ def requestPluginContext = request[CONTROLLER ]? . pluginContextPath
6363 if (attrs. src) {
6464 out << ' <script type="text/javascript" src="'
6565 out << grailsAttributes. getApplicationUri(request)
Original file line number Diff line number Diff line change @@ -126,6 +126,18 @@ public class JavaScriptTagLibTests extends AbstractGrailsTagTests {
126126 assertEquals (" <script type=\" text/javascript\" src=\" /myapp/js/lib.js\" ></script>" + System . getProperty(" line.separator" ),sw. toString())
127127 }
128128 }
129+
130+ public void testJSSrcWithNoController (){
131+ StringWriter sw = new StringWriter ()
132+ PrintWriter pw = new PrintWriter (sw)
133+ withTag(" javascript" ,pw) { tag ->
134+ def attrs = [src :' lib.js' ]
135+ setRequestContext()
136+ request. setAttribute(GrailsApplicationAttributes . CONTROLLER , null );
137+ tag. call(attrs) { }
138+ assertEquals (" <script type=\" text/javascript\" src=\" /myapp/js/lib.js\" ></script>" + System . getProperty(" line.separator" ),sw. toString())
139+ }
140+ }
129141
130142 public void testJSLib (){
131143 StringWriter sw = new StringWriter ()
You can’t perform that action at this time.
0 commit comments