New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

elements-lite

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elements-lite - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

.jshintrc

190

elements.js

@@ -5,4 +5,4 @@

/*
* @version 0.2.2
* @date 2014-05-24
* @version 0.2.4
* @date 2014-06-28
* @stability 1 - Experimental

@@ -15,3 +15,2 @@ * @author Lauri Rooden <lauri@rooden.ee>

/* TODO: find ways for automated testing

@@ -28,3 +27,2 @@ * http://www.browserscope.org/user/tests/howto

/*

@@ -35,3 +33,2 @@ * Examples:

function El(name, args) {

@@ -49,7 +46,4 @@ var el

/*
* NOTE: IE’s cloneNode operation consolidates the two text nodes together as one
* http://brooknovak.wordpress.com/2009/08/23/ies-clonenode-doesnt-actually-clone/
*/
// NOTE: IE’s cloneNode operation consolidates the two text nodes together as one
// http://brooknovak.wordpress.com/2009/08/23/ies-clonenode-doesnt-actually-clone/
el = (elCache[name] || (elCache[name] = doc.createElement(name))).cloneNode(true).set(pre)

@@ -61,3 +55,2 @@

/* TODO: Extend El api

@@ -82,4 +75,2 @@ * add El.siblings( [selector ] )

/*

@@ -96,11 +87,8 @@ * ### element.append( content, [ before ] ) -> element

proto.append = function(child, before) {
var t = this
var el = this
if (child) {
if (typeof child == "string" || typeof child == "number") child = El.text(child)
else if ( !("nodeType" in child) && "length" in child ) {
/*
* document.createDocumentFragment is unsupported in IE5.5
* fragment = "createDocumentFragment" in doc ? doc.createDocumentFragment() : El("div")
*/
// document.createDocumentFragment is unsupported in IE5.5
// fragment = "createDocumentFragment" in doc ? doc.createDocumentFragment() : El("div")
for (

@@ -110,23 +98,20 @@ var len = child.length

, fragment = doc.createDocumentFragment();
i < len
; ) proto.append.call(fragment, child[i++]);
i < len; ) proto.append.call(fragment, child[i++]);
child = fragment
}
if (child.nodeType) t.insertBefore(child,
(before === true ? t.firstChild :
typeof before == "number" ? t.childNodes[
before < 0 ? t.childNodes.length - before - 2 : before
if (child.nodeType) el.insertBefore(child,
(before === true ? el.firstChild :
typeof before == "number" ? el.childNodes[
before < 0 ? el.childNodes.length - before - 2 : before
] : before) || null
)
child.append_hook && child.append_hook()
//"child_hook" in t && t.child_hook()
if (child.append_hook) child.append_hook()
//"child_hook" in el && el.child_hook()
}
return t
return el
}
proto.after = function(silbing, before) {
/*
* call append from proto so it works with DocumentFragment
*/
// call append from proto so it works with DocumentFragment
proto.append.call(silbing.parentNode, this, before ? silbing : silbing.nextSibling)

@@ -142,6 +127,4 @@ return this

proto.hasClass = function(name) {
/*
* http://jsperf.com/regexp-indexof-perf/32
* return (" "+this.className+" ").indexOf(" "+name+" ") > -1
*/
// http://jsperf.com/regexp-indexof-perf/32
// return (" "+this.className+" ").indexOf(" "+name+" ") > -1
return RegExp("\\b" + name + "\\b").test(this.className)

@@ -151,11 +134,11 @@ }

proto.addClass = function(name) {
var t = this
t.className += t.className == "" ? name : t.hasClass(name) ? "" : " " + name
return t
var el = this
el.className += !el.className ? name : el.hasClass(name) ? "" : " " + name
return el
}
proto.rmClass = function(name) {
var t = this
t.className = (" "+t.className+" ").replace(" "+name+" "," ").trim()
return t
var el = this
el.className = (" "+el.className+" ").replace(" "+name+" "," ").trim()
return el
}

@@ -170,14 +153,13 @@

proto.empty = function() {
var t = this, node
while (node = t.firstChild) t.kill.call(node)
return t
for (var node, el = this; node = el.firstChild; ) el.kill.call(node)
return el
}
proto.kill = function() {
var t = this
t.parentNode && t.parentNode.removeChild(t)
Event.removeAll && Event.removeAll(t)
t.kill_hook && t.kill_hook()
t.empty && t.empty()
return t
var el = this
if (el.parentNode) el.parentNode.removeChild(el)
if (Event.removeAll) Event.removeAll(el)
if (el.kill_hook) el.kill_hook()
if (el.empty) el.empty()
return el
}

@@ -197,7 +179,7 @@

var val
, t = this
, el = this
, key = typeof args
if (!args) return t
if (key == "string" || key == "number" || args.nodeType || "length" in args) t.append(args)
if (!args) return el
if (key == "string" || key == "number" || args.nodeType || "length" in args) el.append(args)
else for (key in args)

@@ -210,59 +192,48 @@ /** hasOwnProperty

// El uses class
if (key == "class") t.addClass(val)
else if (!val) t.removeAttribute(key)
if (key == "class") el.addClass(val)
else if (!val) el.removeAttribute(key)
else if (typeof val == "string") {
/*
* Note: IE5-7 doesn't set styles and removes events when you try to set them.
*
* in IE6, a label with a for attribute linked to a select list
* will cause a re-selection of the first option instead of just giving focus.
* http://webbugtrack.blogspot.com/2007/09/bug-116-for-attribute-woes-in-ie6.html
*/
t.setAttribute(key, val)
// Note: IE5-7 doesn't set styles and removes events when you try to set them.
//
// in IE6, a label with a for attribute linked to a select list
// will cause a re-selection of the first option instead of just giving focus.
// http://webbugtrack.blogspot.com/2007/09/bug-116-for-attribute-woes-in-ie6.html
el.setAttribute(key, val)
/*
* there are bug in IE<9 where changed 'name' param not accepted on form submit
* The JScript engine used in IE doesn't recognize vertical tabulation character
* oldIE = "\v" == "v"
*
* IE8 and below also support document.createElement('<P>')
*
* http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/
* http://msdn.microsoft.com/en-us/library/ms536614(VS.85).aspx
*/
// there are bug in IE<9 where changed 'name' param not accepted on form submit
// The JScript engine used in IE doesn't recognize vertical tabulation character
// oldIE = "\v" == "v"
//
// IE8 and below also support document.createElement('<P>')
//
// http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/
// http://msdn.microsoft.com/en-us/library/ms536614(VS.85).aspx
if ((key == "id" || key == "name") && "\v" == "v") {
t.mergeAttributes(doc.createElement('<INPUT '+key+'="' + val + '"/>'), false)
el.mergeAttributes(doc.createElement('<INPUT '+key+'="' + val + '"/>'), false)
}
}
else t[key] = val
} else el[key] = val
}
return t
return el
}
// In Safari 2.x, innerText functions properly only
// if an element is neither hidden (via style.display == "none")
// nor orphaned from the document.
// Otherwise, innerText results in an empty string.
//
// textContent is suported from IE9
//
// Opera 9-10 have Node.text, Node.textContent
/*
* In Safari 2.x, innerText functions properly only
* if an element is neither hidden (via style.display == "none")
* nor orphaned from the document.
* Otherwise, innerText results in an empty string.
*
* textContent is suported from IE9
*
* Opera 9-10 have Node.text, Node.textContent
*/
proto.txt = function(newText) {
var t = this
, attr = "textContent" in t ? "textContent" : "innerText"
return arguments.length ? (t[attr] = newText) : t[attr]
var el = this
, attr = "textContent" in el ? "textContent" : "innerText"
return arguments.length ? (el[attr] = newText) : el[attr]
}
/*
* Expose slow find for testing
*
* TODO: look another way
* http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed
*/
// Expose slow find for testing
//
// TODO: look another way
// http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed

@@ -293,5 +264,3 @@ proto._find = function(sel) {

function(sel) {
/*
* Note: IE8 don't support :disabled
*/
// Note: IE8 don't support :disabled
return this.querySelector(sel)

@@ -307,8 +276,4 @@ } : proto._find

// IE 6-7
if (proto === El[protoStr]) {
/*
* IE 6-7
*/
var create = doc.createElement

@@ -319,8 +284,6 @@ doc.createElement = function(name) {return extend(create(name))}

/*
* Remove background image flickers on hover in IE6
*
* You could also use CSS
* html { filter: expression(document.execCommand("BackgroundImageCache", false, true)); }
*/
// Remove background image flickers on hover in IE6
//
// You could also use CSS
// html { filter: expression(document.execCommand("BackgroundImageCache", false, true)); }
/*@cc_on try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}@*/

@@ -331,3 +294,2 @@ }

El.get = function(id) {

@@ -350,6 +312,4 @@ if (typeof id == "string") id = doc.getElementById(id)

root.El = El
}(window, document, "prototype")
{
"name": "elements-lite",
"version": "0.2.3",
"version": "0.2.4",
"stability": 1,

@@ -34,5 +34,5 @@ "license": "MIT",

"buildman": {
"min.js": "elements.js",
"haml-min.js": "haml.js",
"responsive-min.js": "responsive.js"
"dist/elements-min.js": "elements.js",
"dist/haml-min.js": "lib/haml.js",
"dist/responsive-min.js": "lib/responsive.js"
},

@@ -39,0 +39,0 @@ "testling": {

@@ -9,4 +9,4 @@ [1]: https://secure.travis-ci.org/litejs/elements-lite.png

@version 0.2.2
@date 2014-05-24
@version 0.2.4
@date 2014-06-28
@stability 1 - Experimental

@@ -13,0 +13,0 @@

global.Event = global.Event || {}
global.i18n = require("../i18n.js").i18n
global.i18n = require("../lib/i18n.js").i18n

@@ -8,3 +8,3 @@ require("browser-upgrade-lite")

require("../")
require("../haml")
require("../lib/haml")

@@ -249,6 +249,11 @@ function getString(node) {

it ( "should render data to elements" ).
equal(getString(t1 = El.haml("a>b>i =text:hello {name}")), '<a><b><i data-bind="text:hello {name}"></i></b></a>').
equal(getString(t1.render({name:"world"})), '<a><b><i data-bind="text:hello {name}">hello world</i></b></a>').
equal(getString(t1.render({name:"moon"})), '<a><b><i data-bind="text:hello {name}">hello moon</i></b></a>').
equal(getString(t1 = El.haml("a>b>i =txt:hello {name}")), '<a><b><i data-bind="txt:hello {name}"></i></b></a>').
equal(getString(t1.render({name:"world"})), '<a><b><i data-bind="txt:hello {name}">hello world</i></b></a>').
equal(getString(t1.render({name:"moon"})), '<a><b><i data-bind="txt:hello {name}">hello moon</i></b></a>').
it ( "should show set DOM propperty when plugin not found" ).
equal(getString(t1 = El.haml("a =unknown_plugin:hello {name}")), '<a data-bind="unknown_plugin:hello {name}"></a>').
equal(getString(t1.render({name:"world"})), '<a data-bind="unknown_plugin:hello {name}" unknown_plugin="hello world"></a>').
equal(getString(t1.render({name:"moon"})), '<a data-bind="unknown_plugin:hello {name}" unknown_plugin="hello moon"></a>').
done()

@@ -255,0 +260,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc