Skip to content
Browse files

Prevent duplicate loading of resources with combine option during mul…

…tiple calls to the tags, scripts, and/or css methods for a single page. Ref ticket #6 (2cb1b01090c0cdfd96c2c54aa45538ac).
  • Loading branch information...
1 parent fbc3e44 commit 0ceada8d750c0cbafc34df40b38cbd93a357cca8 @cauld cauld committed Nov 21, 2009
Showing with 20 additions and 2 deletions.
  1. +20 −2 phploader/loader.php
View
22 phploader/loader.php
@@ -717,12 +717,10 @@ function getAllDependencies($mname, $loadOptional=false, $completed=array()) {
$key .= YUI_OPTIONAL;
}
- /*
if (isset($this->depCache[$key])) {
// $this->log("Using cache " . $mname);
return $this->depCache[$key];
}
- */
$m = $this->modules[$mname];
$mProvides = $this->getProvides($mname);
@@ -1266,6 +1264,9 @@ function processDependencies($outputType, $moduleType, $skipSort=false, $showLoa
// keep track of all the stuff we loaded so that we don't reload
// scripts if the page makes multiple calls to tags
$this->loaded = array_merge($this->loaded, $sorted);
+ if ($this->combine === true) {
+ $this->clearComboLink($outputType);
+ }
// return the raw data structure
if ($outputType == YUI_DATA) {
@@ -1467,6 +1468,23 @@ function getComboLink($type) {
}
/**
+ * Clears the combo url of already loaded modules for a specific resource type. Prevents
+ * duplicate loading of modules if the page makes multiple calls to tags, css, or script.
+ * @method clearComboLink
+ * @param {string} type Resource type (i.e.) YUI_JS or YUI_CSS
+ */
+ function clearComboLink($type) {
+ if ($type == YUI_CSS) {
+ $this->cssComboLocation = null;
+ } else if ($type == YUI_JS) {
+ $this->jsComboLocation = null;
+ } else {
+ $this->cssComboLocation = null;
+ $this->jsComboLocation = null;
+ }
+ }
+
+ /**
* Adds a module the combo collection for a specified resource type
* @method addToCombo
* @param {string} name The module name to add

0 comments on commit 0ceada8

Please sign in to comment.
Something went wrong with that request. Please try again.