Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDOM and Jquery upgrade #300

Merged
merged 5 commits into from
Dec 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bin/yuitest
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ if (!appName || appName.length == 0) {
daemon: {
runAsDaemon: false
},
domPoolSize: {
min: 10,
max: 20
},
session: {
config: {
key: "feather.sid",
Expand Down
4 changes: 0 additions & 4 deletions featherdoc/docs/applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ Your application can be configured via the `config.json` file in the top level a
"enabled": true
}
},
"domPoolSize": {
"min": 10,
"max": 20
},
"environments": {
"unittest": {
"debug": true,
Expand Down
2 changes: 0 additions & 2 deletions featherdoc/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ If the path option is omitted, the default is attempted.
--daemonize (-z): (run command only) - Daemonize this server so it runs in the background
--debug (-d): (run command only) - Starts the app in debug mode (i.e. "node debug")
--debug-inspector (-D): (run command only) - Starts the app in debug mode and hosts node-inspector on port 8888
--dompoolmax (-x): (run command only) - The max size of the dom pool to use
--dompoolmin (-n): (run command only) - The min size of the dom pool to use
--env (-e): (run command only) - The environment to run in (e.g. dev, prod)
--loglevel (-l): (run command only) - The default logging level to use. Options are: all, trace, debug, info, warn, error, off
--outputpath (-o): (run command only) - Path to write std output to when running as a daemon. Default is feather-app.out.
Expand Down
8 changes: 0 additions & 8 deletions featherdoc/docs/configuration reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ TODO:

### authdb

TODO:

## domPoolSize
The DOM pool is used for parsing widgets during startup and at runtime. These settings are used to tune the pool size for performance. When the app starts up, the minimum number of DOM instances are created. If more are needed during processing, more are created (up to max). If _max_ DOMs are in use, any other processing must wait until a DOM is released back into the pool.

* min [10] - The minimum number of DOM instances to create at runtime.
* max [20] - The maximum number of DOM instances to create at runtime.

## environments

Any properties of this object are considered to be a named environment (e.g. "dev" or "prod"). See the _Applications_ documentation for more details.
Expand Down
4 changes: 0 additions & 4 deletions lib/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@
"enabled": true
}
},
"domPoolSize": {
"min": 10,
"max": 20
},
"environments": {
"unittest": {
"debug": true,
Expand Down
66 changes: 31 additions & 35 deletions lib/dom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var jsdom = require("jsdom"),
inherits = require("inherits"),
FSM = require("./fsm"),
ResourcePool = require("./resource-pool"),
fs = require('fs'),
path = require('path'),
jQueryScript = fs.readFileSync(path.join(__dirname, 'jquery.js')),
Expand Down Expand Up @@ -29,12 +28,15 @@ var DomResource = exports.DomResource = function(options) {
DomResource.super.apply(this, arguments);
var me = this;
jsdom.env({
html: emptyDoc,
html: (options ? options.html || emptyDoc : emptyDoc),
src: [
jQueryScript,
jQueryTmplScript
],
done: function(errors, window) {
done: function(error, window) {
if (error) {
console.log("DomResource.load: Error loading scripts. " + error);
}
me.window = window;
me.document = window.document;
me.$ = me.$j = me.jQuery = window.jQuery;
Expand All @@ -44,12 +46,6 @@ var DomResource = exports.DomResource = function(options) {
};

DomResource.prototype = {
/**
* Resets this dom resource's innerHTML to an empty string.
*/
reset: function() {
this.document.innerHTML = emptyDoc;
},
/**
* The collection of states associated with this dom resource.
*/
Expand All @@ -66,41 +62,41 @@ DomResource.prototype = {
inherits(DomResource, FSM);

/**
* @class represents a pool of DOM resources
* @extends ResourcePool
* @class manages use of DOM resources
*/
var DomPool = exports.DomPool = function() {
DomPool.super.apply(this, arguments);
var DomManager = exports.DomManager = function() {
var me = this;
me.domResourceCount = 0;
};

/**
* Returns a DOM object asynchronously via the provided callback function.
* @param {Object} cb callback function that receives a single parameter, the dom.
*/
DomPool.prototype.getResource = function(cb) {
DomPool.super.prototype.getResource.call(this, function(dom) {
DomManager.prototype = {

getResource: function(options, cb) {
var me = this,
dom = new DomResource(options);
dom.onceState("ready", function() {
me.domResourceCount++;
cb(dom);
});
});
};


/**
* Creates a new DOM resource and returns it.
* @returns {DomResource} a new dom resource
*/
DomPool.prototype.createResource = function() {
return new DomResource();
};
},

/**
* Releases a dom resource back to the pool.
* @param {Object} dom the dom to release
*/
DomPool.prototype.release = function(dom) {
dom.reset();
DomPool.super.prototype.release.apply(this, arguments);
};
/**
* Releases a dom resource back to the pool.
* @param {Object} dom the dom to release
*/
release: function(dom) {
var me = this;
dom.window.close(); // jsdom needs the window closed to properly handle javascript memory cleanup
dom.dispose();
me.domResourceCount--;
},

inherits(DomPool, ResourcePool);
resourceStats: function() {
var me = this;
return "Allocated Dom Resource Count is " + me.domResourceCount;
}
};
Loading