Socket
Socket
Sign inDemoInstall

domv

Package Overview
Dependencies
79
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.2.2

75

lib/domv.js

@@ -41,2 +41,3 @@ 'use strict';

* @returns {!boolean}
* @throws {module:domv/lib/Exception} For invalid arguments
*/

@@ -46,2 +47,8 @@ module.exports.isSupported = function(document, checkAll)

var ret;
if (!document)
{
throw new domv.Exception(Error('domv.isSupported() : Missing argument'));
}
ret = !!(

@@ -108,2 +115,3 @@ global.JSON &&

}
return false;

@@ -302,2 +310,3 @@ }

* // <div class="myDiv" data-test="foo">This is my div!</div>
* @throws {module:domv/lib/Exception} For invalid arguments
*/

@@ -312,2 +321,8 @@ module.exports.create = function(document_, nodeName, className)

if (!document ||
!nodeName)
{
throw new domv.Exception(Error('domv.create() : Missing argument'));
}
if (document.isDOMVComponent)

@@ -411,3 +426,3 @@ {

* @param {!external:Document} document_
* @param {!string} tagName_
* @param {string} [tagName_='div']
* @param {...(string|Object.<string, string>)} initialAttributes

@@ -429,2 +444,7 @@ * <p>If a string is passed, a text node is appended.</p>

if (!document)
{
throw new domv.Exception(Error('domv.shorthand() : Missing argument'));
}
if (arguments.length > 2)

@@ -515,2 +535,8 @@ {

var text = text_;
if (!document)
{
throw new domv.Exception(Error('domv.text() : Missing argument'));
}
if (document.isDOMVComponent)

@@ -714,3 +740,3 @@ {

{
throw domv.Exception(Error('Invalid ownerDocument parameter in domv.parseHTMLSnippit(), null'));
throw domv.Exception(Error('Invalid ownerDocument argument in domv.parseHTMLSnippit(), null'));
}

@@ -725,3 +751,3 @@

{
throw domv.Exception(Error('Invalid ownerDocument parameter in domv.parseHTMLSnippit(), it is not really a Document Node'));
throw domv.Exception(Error('Invalid ownerDocument argument in domv.parseHTMLSnippit(), it is not really a Document Node'));
}

@@ -748,3 +774,3 @@

* @see {@link http://www.w3.org/TR/CSS21/syndata.html#strings}
* @param {String} str
* @param {String} [str='undefined']
* @param {boolean} [wrapInQuotes=true] If true, surround the result with quotes: "something"

@@ -755,8 +781,7 @@ * @returns {String}

{
str = str.toString();
str = str + '';
str = str.replace(/[\\"']/g, '\\$&')
.replace(/[\r]/g , '\\d ') // CR
.replace(/[\n]/g , '\\a ') // LF
;
.replace(/[\n]/g , '\\a '); // LF

@@ -772,2 +797,38 @@ if (wrapInQuotes || wrapInQuotes === undefined)

/**
* Given that 'event' is a mouse event, is the left mouse button being held down?.
* @param {!external:Event} event
* @returns {boolean} True if the left mouse button is down
* @throws {module:domv/lib/Exception} For invalid arguments
*/
module.exports.isLeftMouseButton = function(event)
{
if (!event)
{
throw domv.Exception(Error('Missing argument'));
}
/*jshint -W016*/
return event.buttons & 1 ||
event.button === 0;
/* <= IE8 event.button (not supported by this library):
* 1 : Left button
* 2 : Right button
* 4 : Middle button
*
* W3C event.button:
* 0 : Left button
* 2 : Right button
* 1 : Middle button
*
* event.buttons:
* 1 : Left button
* 2 : Right button
* 4 : Wheel button or middle button
* 8 : 4th button (typically the "Browser Back" button)
* 16 : 5th button (typically the "Browser Forward" button)
*/
};
/**
* <p>The Node interface is the primary datatype for the entire Document Object Model.

@@ -774,0 +835,0 @@ * It represents a single node in the document tree. While all objects implementing

2

package.json
{
"name": "domv",
"version": "0.2.1",
"version": "0.2.2",
"author": "Joris van der Wel <joris@jorisvanderwel.com>",

@@ -5,0 +5,0 @@ "description": "Create views as components using DOM. Run the same code on the browser and on the server.",

@@ -57,2 +57,3 @@ 'use strict';

{
test.throws(function(){ domv.isSupported(); }, domv.Exception);
test.ok(domv.isSupported(this.document, false));

@@ -219,4 +220,4 @@ test.ok(domv.isParseHTMLDocumentSupported());

test.throws(function(){ domv.create(); });
test.throws(function(){ domv.create(this.document); });
test.throws(function(){ domv.create(); }, domv.Exception);
test.throws(function(){ domv.create(this.document);}.bind(this), domv.Exception);

@@ -459,3 +460,31 @@ wrapped = domv.create(this.document, 'div');

test.done();
},
'shorthand()': function(test)
{
test.throws(function(){ domv.shorthand(); }, domv.Exception);
// the rest is tested in Component.js
test.done();
},
'isLeftMouseButton()': function(test)
{
test.throws(function(){ domv.isLeftMouseButton(); }, domv.Exception);
test.ok(domv.isLeftMouseButton({
button: 0 // left
}));
test.ok(! domv.isLeftMouseButton({
button: 2 // right
}));
test.ok(domv.isLeftMouseButton({
buttons: 1 | 2 // left and right
}));
test.ok(! domv.isLeftMouseButton({
buttons: 2 // right only
}));
test.done();
}
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc