Steps for reproduction:

  1. Create an arbitrary Webform
  2. CSS/JS: Add a Javascript snippet for your form
  3. Clear Drupal cache (Configuration)

Test with that Javascript snippet:

(function ($) {
  console.log ("javascript called");
})(jQuery);

It works befor clearing cache.

Error after clearing cache:

2016/12/19 07:33:19 [error] 20257#20257: *1863 FastCGI sent in stderr: "PHP message: Error: Unsupported operand types in /var/www/html/modules/webform/webform.module on line 321 #0 /var/www/html/modules/webform/webform.module(296): _webform_asset_alter(Array, Object(Drupal\Core\Asset\AttachedAssets), 'javascript')
#1 /var/www/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(501): webform_js_alter(Array, Object(Drupal\Core\Asset\AttachedAssets), NULL)
#2 /var/www/html/core/lib/Drupal/Core/Asset/AssetResolver.php(276): Drupal\Core\Extension\ModuleHandler->alter('js', Array, Object(Drupal\Core\Asset\AttachedAssets))
#3 /var/www/html/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(298): Drupal\Core\Asset\AssetResolver->getJsAssets(Object(Drupal\Core\Asset\AttachedAssets), true)
#4 /var/www/html/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(161): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries(Object(Drupal\Core\Asset\AttachedAssets), Array)
#5 /var/www/html/core/modules/big_pipe/src/Render/BigPipeResponseAttachme" while reading upstream, client: 192.168.0.6, server: _, request: "GET /form/registrierung HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "www-test.lan", referrer: "https://www-test.felsing.net/admin/structure/webform"

Comments

ip6li created an issue. See original summary.

jrockowitz’s picture

StatusFileSize
new2.17 KB

I can't duplicate the issue. Attached is the form I am using.

What version for Drupal are you using?

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)
ip6li’s picture

Following versions are installed

Drupal core 8.2.4
CAPTCHA 8.x-1.0-alpha1
CDN 8.x-3.0
CKEditor CodeSnippet 8.x-1.6
CKEditor Font Size and Family 8.x-1.0
Composer Manager 8.x-1.0-rc2+1-dev (2016-Jun-22)
ImageMagick 8.x-1.0-alpha5
IMCE 8.x-1.4
JSON/JSONB Field 8.x-1.0-beta1
Mail System 8.x-4.1
Memcache Storage 8.x-1.0-beta2
Monitoring 8.x-1.1
OAuth2 Server 8.x-1.x-dev (2015-Okt-01)
reCAPTCHA 8.x-2.2
Superfish 8.x-1.0-rc5
Symbol 8.x-1.0
Webform 8.x-5.0-beta2

BTW: How did you got complete YAML source from webforms?

ip6li’s picture

Development export of failing form:

uuid: bb6e1cbb-2c9f-4497-81ab-7d631608f81a
langcode: de
status: true
dependencies: {  }
uid: 1
template: false
id: registrierung
title: Registrierung
description: 'Anmeldung an ip6li'
elements: |
  username:
    '#type': fieldset
    '#title': Username
    '#description': 'Der Benutzername in ip6li'
    '#attributes':
      class:
        - 'container-inline clearfix'
    username_field:
      '#type': textfield
      '#title': Benutzername
      '#title_display': invisible
      '#description_display': invisible
      '#required': true
  e_mail_adresse:
    '#type': fieldset
    '#title': 'E-Mail Adresse'
    '#description': 'Das ist die E-Mail Adresse, die Sie bei ip6li bekommen'
    emailadresse_flexbox:
      '#type': flexbox
      '#attributes':
        class:
          - 'form--inline clearfix'
      e_mail_name:
        '#type': textfield
        '#title': 'E-Mail Name'
        '#title_display': invisible
        '#description_display': invisible
        '#field_suffix': ' @'
        '#size': '50'
        '#flex': '2'
        '#wrapper_attributes':
          class:
            - 'container-inline clearfix'
        '#attributes':
          class:
            - 'container-inline clearfix'
        '#required': true
      e_mail_domain:
        '#type': select
        '#title': 'E-Mail Domain'
        '#title_display': invisible
        '#description_display': invisible
        '#flex': '2'
        '#wrapper_attributes':
          class:
            - 'container-inline clearfix'
        '#options':
          ip6.li: ip6.li
          ip6mail.de: ip6mail.de
        '#empty_option': 'Bitte auswählen'
        '#empty_value': none
        '#required': true
css: ''
javascript: |
  (function ($) {
    console.log("javascript called");
  })(jQuery);
settings:
  page: true
  page_submit_path: ''
  page_confirm_path: ''
  form_submit_label: ''
  form_submit_attributes: {  }
  form_exception_message: ''
  form_closed_message: ''
  form_confidential: false
  form_confidential_message: ''
  form_prepopulate: false
  form_prepopulate_source_entity: false
  form_novalidate: false
  form_unsaved: false
  form_disable_back: false
  form_autofocus: false
  form_details_toggle: false
  wizard_progress_bar: true
  wizard_progress_pages: false
  wizard_progress_percentage: false
  wizard_next_button_label: ''
  wizard_next_button_attributes: {  }
  wizard_prev_button_label: ''
  wizard_prev_button_attributes: {  }
  wizard_start_label: ''
  wizard_complete: true
  wizard_complete_label: ''
  preview: 0
  preview_next_button_label: ''
  preview_next_button_attributes: {  }
  preview_prev_button_label: ''
  preview_prev_button_attributes: {  }
  preview_message: ''
  draft: false
  draft_auto_save: false
  draft_button_label: ''
  draft_button_attributes: {  }
  draft_saved_message: ''
  draft_loaded_message: ''
  confirmation_type: page
  confirmation_message: ''
  confirmation_url: ''
  confirmation_attributes: {  }
  confirmation_back: true
  confirmation_back_label: ''
  confirmation_back_attributes: {  }
  limit_total: null
  limit_total_message: ''
  limit_user: null
  limit_user_message: ''
  entity_limit_total: null
  entity_limit_user: null
  results_disabled: false
  results_disabled_ignore: false
  token_update: false
access:
  create:
    roles:
      - anonymous
      - authenticated
    users: {  }
  view_any:
    roles: {  }
    users: {  }
  update_any:
    roles: {  }
    users: {  }
  delete_any:
    roles: {  }
    users: {  }
  purge_any:
    roles: {  }
    users: {  }
  view_own:
    roles: {  }
    users: {  }
  update_own:
    roles: {  }
    users: {  }
  delete_own:
    roles: {  }
    users: {  }
handlers: {  }
jrockowitz’s picture

StatusFileSize
new404.11 KB

Form is working fine on my local dev. See below screenshot.

Can you test your form using a plain D8 install? Maybe try https://simplytest.me/project/drupal/8.2.x?add[]=webform

ip6li’s picture

Problem was caused by enabled experimental Drupal 8 feature BigPipe. After disabling that, Webform works with my Javascript snippet.

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Needs work

Okay, that is fixable. I will look into it.

jrockowitz’s picture

Here are the steps that I am using to replicate the issue using simplytest.me.

  • Goto https://simplytest.me/project/drupal/8.2.x?add[]=webform
  • Create the site
  • Enable webform and bigpipe. (/admin/modules)
  • Import form from #6 (/admin/config/development/configuration/single/import)
  • Goto form and it is blank (/form/registrierung)
  • Error log reports "Notice: Undefined index: //webform/{webform}/assets/javascript in _webform_asset_alter() (line 320 of /home/dgwh3/www/modules/webform/webform.module) #0"
  • Refresh fixes the issue
  • Clear cache breaks it again

  • jrockowitz committed fb11900 on 8.x-5.x
    Issue #2837491 by jrockowitz, ip6li: Custom Javascript: "Error:...
jrockowitz’s picture

Status: Needs work » Fixed

Fixed! Please download or checkout the latest dev release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.