Sandbox javascript module

Is it possible to use the sandbox javascript module from DOM manipulation? Example fo

var Core = { 
    register: function(config){config.init()},
    publicApi: {
        msgbox: function(msg){alert(msg)} 
    } 
}
Core.register({
    name: 'testmodule',
    init: function(){
        /* from there i want to see only function defined in Core.publicApi, no jQuery direct access, no DOM */
    }
});
+3
source share
2 answers

I suggest reading this slidedeck in an application , Sandbox, and Module in Slideshare called Creating a JavaScript Module for JavaScript in Gilt .

+3
source

, : , . , Core.publicApi document . , , Javascript, .

, , window:

var window = {"Core": Core};

no ( , alert) . , , API.

(, _unsandboxed - ) window, API . , , , _unsandboxed.

0

Source: https://habr.com/ru/post/1735723/


All Articles