Skip to content

Commit 9e7916c

Browse files
committed
Fix from the refactor where namespaces were removed
1 parent 4294b3f commit 9e7916c

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

dist/jpack.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@htmlguyllc/jpack",
3-
"version": "4.1.15",
3+
"version": "4.1.16",
44
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities",
55
"keywords": [
66
"javascript",

src/jpack.compiled.js

Lines changed: 23 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jpack.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ import {strings} from "../es/strings";
88
import {type_checks} from "../es/type_checks";
99
import {User} from "../es/user";
1010

11-
//create an array of all components
12-
const components = [dom, events, XHRForm, FormFromURL, navigation, request, Site, strings, type_checks, User];
11+
//create a key:val object of all components
12+
const components = {
13+
dom:dom,
14+
events:events,
15+
XHRForm:XHRForm,
16+
FormFromURL:FormFromURL,
17+
navigation:navigation,
18+
request:request,
19+
Site:Site,
20+
strings:strings,
21+
type_checks:type_checks,
22+
User:User
23+
};
1324

1425
/**
1526
* Call this function to tie all jpack components directly to the window for global use
@@ -30,23 +41,16 @@ const components = [dom, events, XHRForm, FormFromURL, navigation, request, Site
3041
const setGlobal = function(namespace){
3142
namespace = typeof namespace === 'string' ? namespace : null;
3243

33-
//loop through components, objects, plugin_wrappers, and utilities
34-
components.forEach(function(object){
35-
//for each component within those
36-
for (var property in object) {
37-
//get actual properties
38-
if (object.hasOwnProperty(property)) {
39-
//set them on window so they're available globally
40-
//set them on window so they're available globally
41-
if( namespace ){
42-
if( typeof window[namespace] === "undefined" ){ window[namespace] = {}; }
43-
window[namespace][property] = self[property];
44-
}else{
45-
window[property] = self[property];
46-
}
47-
}
44+
//for each function within events
45+
for (const key in components) {
46+
//set them on window so they're available globally
47+
if( namespace ){
48+
if( typeof window[namespace] === "undefined" ){ window[namespace] = {}; }
49+
window[namespace][key] = components[key];
50+
}else{
51+
window[key] = components[key];
4852
}
49-
});
53+
}
5054
};
5155

5256
//extend components to include the setGlobal method

0 commit comments

Comments
 (0)