This patch does what the title says. This allows for the possibility of ultimately allowing the option to override function parameters for #315100: Allow to add JS/CSS libraries (sets of files, settings, and dependent libraries).
That means that to reset js, you'll call drupal_add_js(NULL, 'reset'); rather than drupal_add_js(NULL, NULL, TRUE);
For completeness, we do the same with drupal_add_css. (Hoping we can merge those two functions later for cleaner code.) This patch also takes care of all simpletests for the two. I grepped core for drupal_add_js(NULL, NULL, TRUE); and drupal_add_css(NULL, NULL, TRUE); but found nothing.
There's also the possibility that something like drupal_add_js('myfile.js', 'header', TRUE); is called, which would be bad practice now. I did a quick scan through the API and didn't see anything, so it's probably safe.
Comment | File | Size | Author |
---|---|---|---|
#8 | 345973.patch | 6.3 KB | RobLoach |
#6 | 345973.patch | 5.96 KB | RobLoach |
#4 | 345973.patch | 5.91 KB | RobLoach |
#2 | drupal_add_js_reset.patch | 6.36 KB | aaron |
drupal_add_js_reset.patch | 6.38 KB | aaron | |
Comments
Comment #1
RobLoachThis is wicked awesome cool, but noticed this:
Would be good to have the two spaces in there. I'll be able to hit this up sometime in the next 12 hours.
Comment #2
aaron CreditAttribution: aaron commentedthanks for catching that. here's an updated patch.
Comment #3
RobLoachYay!
Comment #4
RobLoachSorry, thought I should remove the fuzzies. Didn't change anything code-wise.
Comment #5
quicksketchHrm, it seems to me that the documentation for the 'reset' parameter is inaccurate.
This doesn't seem to be the case, the processing continues even after the reset. So you could in theory add CSS/JS file at the same time as resetting all the current files. Should we add a "return" immediately following the
if (options['reset'])
or should we adjust the docs? The $options['reset'] option also needs a much better description, since it doesn't say what it actually does.Comment #6
RobLoachComment #7
mfer CreditAttribution: mfer commentedCode looks good. Tests pass. This is a simple change.
Comment #8
RobLoachWebchick asked for a test.
Comment #9
webchickAwesome, thanks!!
Committed to HEAD. This needs documentation in the upgrade docs, it looks like.
Comment #10
RobLoachYay, thanks a lot, Matt and Aaron. Docs here, if there's anything missing there, please feel free to hack away.
Comment #11
RobLoachUhh, fixed. Next step is #259368: Allow Inline CSS in drupal_add_css, I believe.....