Skip to content

Commit

Permalink
feature(js): Allow canceling a previous elgg_require_js() call
Browse files Browse the repository at this point in the history
Fixes #9074
  • Loading branch information
mrclay committed Oct 26, 2015
1 parent 017b787 commit 375be5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions engine/classes/Elgg/Amd/Config.php
Expand Up @@ -91,6 +91,7 @@ public function removePath($name, $path = null) {
* deps: array Dependencies
* exports: string Name of the shimmed module to export
* @return void
* @throws \InvalidParameterException
*/
public function addShim($name, array $config) {
$deps = elgg_extract('deps', $config, array());
Expand Down
12 changes: 12 additions & 0 deletions engine/lib/elgglib.php
Expand Up @@ -219,6 +219,18 @@ function elgg_require_js($name) {
_elgg_services()->amdConfig->addDependency($name);
}

/**
* Cancel a request to load an AMD module onto the page.
*
* @note The elgg, jquery, and jquery-ui modules cannot be cancelled.
*
* @param string $name The AMD module name.
* @return void
* @since 2.1.0
*/
function elgg_unrequire_js($name) {
_elgg_services()->amdConfig->removeDependency($name);
}

/**
* Get the JavaScript URLs that are loaded
Expand Down

0 comments on commit 375be5f

Please sign in to comment.