domv
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -8,3 +8,10 @@ 'use strict'; | ||
var domv = module.exports; | ||
var jsdom = require('jsdom'); | ||
var jsdom = {}; | ||
try | ||
{ | ||
jsdom = require('jsdom'); | ||
} | ||
catch(err) | ||
{ | ||
} | ||
@@ -607,3 +614,3 @@ /** @constant {!module:domv/lib/Component} */ | ||
} | ||
else | ||
else if (global.document && global.document.implementation) | ||
{ | ||
@@ -634,2 +641,6 @@ doc = global.document.implementation.createHTMLDocument(' '); | ||
} | ||
else | ||
{ | ||
throw new domv.Exception(Error('Unable to find a Document implementation in domv.createHtmlDomDocument(). The browser is too old, or jsdom is not installed (node.js/io.js)')); | ||
} | ||
}; | ||
@@ -664,3 +675,3 @@ | ||
// Note: package.json excludes jsdom from browserify | ||
/* istanbul ignore else : Only called within webbrowsers */ | ||
/* istanbul ignore else : Only called within web browsers */ | ||
if (jsdom.jsdom) | ||
@@ -684,4 +695,4 @@ { | ||
{ | ||
// Safari | ||
throw domv.Exception(Error('Unable to find a DOM parser implementation in domv.parseHTMLDocument()')); | ||
// Safari / jsdom missing | ||
throw domv.Exception(Error('Unable to find a DOM parser implementation in domv.parseHTMLDocument(). The browser is too old, or jsdom is not installed (node.js/io.js)')); | ||
} | ||
@@ -688,0 +699,0 @@ |
'use strict'; | ||
var Throwable = require('throwable'); | ||
/** The base class for any exception that originates from this library | ||
@@ -23,54 +25,7 @@ * | ||
/* istanbul ignore if */ | ||
if (typeof wrapped !== 'object') | ||
{ | ||
throw Error('Exception should always wrap an Error!'); | ||
} | ||
// Wrap the Error so that the stack, lineNumber, fileName, etc is correct | ||
this.wrapped = wrapped; | ||
this.wrapped.name = 'domv.Exception'; | ||
Throwable.call(this, wrapped); | ||
this.name = 'domv.Exception'; | ||
} | ||
require('inherits')(Exception, Throwable); | ||
function wrap(attr) | ||
{ | ||
Object.defineProperty(Exception.prototype, attr, { | ||
get: function() | ||
{ | ||
return this.wrapped ? this.wrapped[attr] : /* istanbul ignore next */ void 123; | ||
} | ||
}); | ||
} | ||
Exception.prototype = Object.create(global.Error.prototype); | ||
Exception.prototype.constructor = Exception; | ||
/** Always true for instances of this class. | ||
* <p>Use this attribute to determine if an object is a Component. | ||
* This would let you create an object compatible with this API, | ||
* without having to use Component as a super type.</p> | ||
* @member {!boolean} isDOMVException | ||
* @memberOf module:domv/lib/Exception | ||
* @constant | ||
* @instance | ||
*/ | ||
Object.defineProperty(Exception.prototype, 'isDOMVException', { | ||
enumerable: false, | ||
configurable: false, | ||
writable: false, | ||
value: true | ||
}); | ||
wrap('name'); | ||
wrap('message'); | ||
wrap('stack'); | ||
wrap('fileName'); | ||
wrap('lineNumber'); | ||
wrap('columnNumber'); | ||
Exception.prototype.toString = function() | ||
{ | ||
return this.wrapped.toString(); | ||
}; | ||
module.exports = Exception; | ||
module.exports = Exception; |
{ | ||
"name": "domv", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": "Joris van der Wel <joris@jorisvanderwel.com>", | ||
@@ -39,2 +39,5 @@ "description": "Create views as components using DOM. Run the same code on the browser and on the server.", | ||
"inherits": "^2.0.1", | ||
"throwable": "^1.0.0" | ||
}, | ||
"optionalDependencies": { | ||
"jsdom": "^3.1.0" | ||
@@ -55,3 +58,3 @@ }, | ||
"documentation": "jsdoc -d ./jsdoc --pedantic --verbose lib/domv.js lib/Component.js lib/Exception.js lib/HtmlDocument.js && jsdoc2md --src lib/domv.js lib/Component.js lib/Exception.js lib/HtmlDocument.js > ./jsdoc/api.md", | ||
"bundle": "browserify --outfile build/domv.js --standalone domv ./lib/domv.js" | ||
"bundle": "browserify --outfile build/domv.js -r ./lib/domv.js:domv && browserify --outfile build/domv-umd.js --standalone domv ./lib/domv.js" | ||
}, | ||
@@ -58,0 +61,0 @@ "jshintConfig": { |
19
350723
3
5327
+ Addedthrowable@^1.0.0
+ Addednan@2.19.0(transitive)
+ Addedthrowable@1.0.3(transitive)
- Removedjsdom@^3.1.0
- Removednan@2.20.0(transitive)