We're building a custom field implementation based upon the chosen library, however we're encountering some loading order issues. As it turns out the "chosen library" javascript file is defined to be part of the JS_DEFAULT group. Is this by design? IMHO it would make sense to define it in the JS_LIBRARY group so that it is loaded early and any code can be sure the file is included.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Erik Frèrejean’s picture

h3rj4n’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: chosen-define_library_in_library_group-2457619-1.diff, failed testing.

Erik Frèrejean’s picture

Corrected patch.

Erik Frèrejean’s picture

Status: Needs work » Needs review
maximpodorov’s picture

m4olivei’s picture

Version: 7.x-2.0-beta4 » 7.x-2.x-dev
FileSize
448 bytes

Re-rolled and slightly updated for 7.x-2.x-dev (also applies to 7.x-2.x-beta4). When you expose JS through hook_library, the default group is JS_LIBRARY, which is what we want. Therefore, I've just removed any defined options, and that should give us what we want and avoid unexpected behaviour. For example as it is, the group is the string 'JS_LIBRARY', which has the effect of putting the script in it's own aggregate all the time.

hgoto’s picture

I think m4olivei's approach is good.

Seeing the file common.inc in core, the value of `group` should be a number at least.

- JS_LIBRARY: -100
- JS_DEFAULT: 0
- JS_THEME: 100

The current value 'JS_LIBRARY' is a string and should be changed to a constant `JS_LIBRARY` or the surrounding array should become empty as m4olivei proposed.

I updated m4olivei's patch for the latest version. (Drupal 8 uses a different sytem for libraries and there's no same problem for Drupal 8.)

I would appreciate if another person would review this.

hgoto’s picture

  • nagy.balint committed 6631e9e on 7.x-2.x authored by m4olivei
    Issue #2457619 by hgoto, Erik Frèrejean, m4olivei: Library defined in "...
nagy.balint’s picture

Status: Needs review » Fixed

Thanks.

hgoto’s picture

Thank you!

Status: Fixed » Closed (fixed)

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