Uploaded image for project: 'Magnolia Demo Projects'
  1. Magnolia Demo Projects
  2. MGNLDEMO-332

Stories page has invalid embedded JavaScript

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: magnolia-travels
    • Labels:
      None

      Description

      On the stories page there is some imbedded JavaScript. Line 317 of this page https://demopublic.magnolia-cms.com/stories.html.

      <script language="javascript">
      
          (function () {
              const players = [];
              const iframes = document.getElementsByTagName('iframe');
              for (let i = 0; i < iframes.length; i++) {
                  const iframe = iframes[i];
                  const classList = iframe.classList;
                  classList.add('opacity-zero');
                  players[i] = new Vimeo.Player(iframe);
      
                  players[i].on('timeupdate', function(event) {
                      if (event.seconds > 0.1) {
                          classList.remove('opacity-zero');
                          classList.add('opacity-full');
                          players[i].off('timeupdate');
                      }
                  });
              } 
          })()
      </script>
      

      Tried several validators such as https://www.piliapp.com/javascript-validator/

      When trying to compress the page I got this error.

      [ERROR] HtmlCompressor: "missing ; after for-loop initializer" at line [6:19] during JavaScript compression:         for (let i = 0; i < iframes.length; i++) {
      [ERROR] HtmlCompressor: "missing ; before statement" at line [6:48] during JavaScript compression:         for (let i = 0; i < iframes.length; i++) {
      [ERROR] HtmlCompressor: "missing ) in parenthetical" at line [20:5] during JavaScript compression:     })()
      [ERROR] HtmlCompressor: "syntax error" at line [20:6] during JavaScript compression:     })()
      [ERROR] HtmlCompressor: "Compilation produced 4 syntax errors." at line [1:0] during JavaScript compression
      Feb 12, 2020 2:18:56 PM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet [default] in context with path [/pro-5.7-webapp] threw exception
      org.mozilla.javascript.EvaluatorException: Compilation produced 4 syntax errors.
      	at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor$DefaultErrorReporter.runtimeError(YuiJavaScriptCompressor.java:93)
      	at org.mozilla.javascript.Parser.parse(Parser.java:402)
      	at org.mozilla.javascript.Parser.parse(Parser.java:347)
      	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
      	at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:532)
      	at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.compress(YuiJavaScriptCompressor.java:53)
      	at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compressJavaScript(HtmlCompressor.java:946)
      	at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processScriptBlocks(HtmlCompressor.java:881)
      	at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processPreservedBlocks(HtmlCompressor.java:771)
      	at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:220)
      	at info.magnolia.html.compressor.filter.HtmlCompressorFilter.doFilter(HtmlCompressorFilter.java:70)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                rgange Richard Gange
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: