Scope is used everywhere in Drupal core and doesn't really mean the same thing for JavaScript, so we should rename it to "region".
Scope is used everywhere in Drupal core and doesn't really mean the same thing for JavaScript, so we should rename it to "region".
Comments
Comment #1
sunDiscussion on IRC revealed that albeit "scope" allows to also place JS in theme regions, scopes are poorly named.
The scope "header" does not add to the "header" region, it actually adds to "html_head"; proper region name would probably be "head".
The scope "footer" does not add to the "footer" region, it actually adds to "closure"; proper region name would probably be "closure".
Also, this uncovered that one is not even able to add JS to the "header" or "footer" regions of a theme. So renaming "scope" to "region" in drupal_add_js()'s $options array, as well as fixing the special scope names to use proper page regions (head/closure) is badly needed.
Comment #2
mfer commentedShould it be renamed to region since the name region doesn't quite mean the same thing as region elsewhere in drupal? For example, in the theme system. If I add a region called 'blue smurf' and try to add js via drupal_add_js to the blue smurf region it won't render.
Comment #3
sunOf course, you'd have to use the internal region name, i.e. "blue_smurf".
This issue depends on #315798: JavaScript Patch #2: Weight, hence marking as postponed.
Comment #4
robloachThe "blue_smurf" region is an absolute must for this issue.
Comment #5
sunIs this still an issue?
Comment #6
robloachYeah, we're still using "scope" for drupal_add_js(). Think this is Drupal 8 material?
Comment #7
sunI'm a bit baffled.
1) I don't think it makes sense to rename 'scope' for drupal_add_js(), when considering our long-term goal to "merge" JS/CSS into generic support file/page requisite helper functions.
2) Looking at how 'scope' is used, it seems that 'region' would be wrong, as 'header' and 'footer' are no regions, but special locations html.tpl.php. Specifying anything else seems to require to invoke drupal_get_js() manually for that custom scope.
I'd suggest to close this issue in favor of 1).
Comment #8
robloachSounds good with me! I think this was one of the drupal_add_js() fixings issues that we created from the original split.
Comment #9
hass commentedAny way to make
page_topa scope if I need to add JS code to this region?