Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jss

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

examples/topcoat/build.js

2

bower.json
{
"name": "jss",
"description": "Dynamic stylesheets for web components.",
"version": "0.2.9",
"version": "0.2.10",
"author": {

@@ -6,0 +6,0 @@ "name": "Oleg Slobodskoi",

@@ -127,3 +127,2 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jss=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

if (!this.attributes.media) this.attributes.media = 'screen'
if (!this.attributes.title) this.attributes.title = 'Generated by jss.'
this.element = this.createElement()

@@ -334,2 +333,4 @@

var toString = Object.prototype.toString
/**

@@ -344,25 +345,24 @@ * Handle `extend` property.

if (!style) return
if (!style || !style.extend) return
var extend = style.extend
if (!extend) return
var newStyle = {}
var prop
// Copy extend style.
if ('length' in extend) {
for (var i = 0; i < extend.length; i++) {
for (prop in extend[i]) newStyle[prop] = extend[i][prop]
;(function extend(style) {
if (toString.call(style.extend) == '[object Array]') {
for (var i = 0; i < style.extend.length; i++) {
extend(style.extend[i])
}
} else {
for (var prop in style.extend) {
if (prop == 'extend') extend(style.extend.extend)
else newStyle[prop] = style.extend[prop]
}
}
} else {
for (prop in extend) newStyle[prop] = extend[prop]
}
// Copy base style.
for (var prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}
}(style))
// Copy original style.
for (prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}

@@ -369,0 +369,0 @@ rule.style = newStyle

@@ -1,2 +0,2 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jss=e()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports=require("./lib/index")},{"./lib/index":4}],2:[function(require,module,exports){"use strict";var uid=0;var processors=[];function Rule(selector,style,stylesheet){if(typeof selector=="object"){stylesheet=style;style=selector;selector=null}if(selector){this.selector=selector}else{this.className=Rule.NAMESPACE_PREFIX+"-"+uid;uid++;this.selector="."+this.className}this.stylesheet=stylesheet;this.style=style}module.exports=Rule;Rule.NAMESPACE_PREFIX="jss";Rule.addPreprocessor=function(fn){processors.push(fn);return processors};Rule.prototype.runPreprocessors=function(){for(var i=0;i<processors.length;i++){processors[i](this)}return this};var hasKeyframes=/@keyframes/;Rule.prototype.toString=function(){var isKeyframe=hasKeyframes.test(this.selector);var style=this.style;var str=this.selector+" {";for(var prop in style){var value=style[prop];if(typeof value=="object"){var valueStr="{";for(var prop2 in value){valueStr+="\n "+prop2+": "+value[prop2]+";"}valueStr+="\n }";value=valueStr}else{value+=";"}str+="\n "+prop+(isKeyframe?" ":": ")+value}str+="\n}";return str}},{}],3:[function(require,module,exports){"use strict";var Rule=require("./Rule");function Stylesheet(rules,named,attributes){if(typeof named=="object"){attributes=named;named=false}this.element=null;this.attached=false;this.named=named||false;this.rules={};this.attributes=attributes||{};this.classes={};this.text="";if(!this.attributes.type)this.attributes.type="text/css";if(!this.attributes.media)this.attributes.media="screen";if(!this.attributes.title)this.attributes.title="Generated by jss.";this.element=this.createElement();if(rules)this.createRules(rules)}module.exports=Stylesheet;Stylesheet.prototype.attach=function(){if(this.attached)return this;if(!this.text){this.text=this.toString();this.element.innerHTML="\n"+this.text+"\n"}document.head.appendChild(this.element);this.attached=true;return this};Stylesheet.prototype.detach=function(){if(!this.attached)return this;this.element.parentNode.removeChild(this.element);this.attached=false;return this};Stylesheet.prototype.addRule=function(key,style){var rule=this.createRule(key,style);var sheet=this.element.sheet;sheet.insertRule(rule.toString(),sheet.cssRules.length);return rule};Stylesheet.prototype.addRules=function(rules){for(var key in rules){this.addRule(key,rules[key])}return this};Stylesheet.prototype.getRule=function(key){return this.rules[key]};Stylesheet.prototype.toString=function(){var str="";var rules=this.rules;for(var key in rules){if(str)str+="\n";str+=rules[key].toString()}return str};Stylesheet.prototype.createRule=function(key,style){var selector,name;if(this.named)name=key;else selector=key;var rule=new Rule(selector,style,this);this.rules[name||rule.selector]=rule;if(this.named)this.classes[name]=rule.className;rule.runPreprocessors();return rule};Stylesheet.prototype.createRules=function(rules){for(var key in rules){this.createRule(key,rules[key])}return this};Stylesheet.prototype.createElement=function(){var el=document.createElement("style");for(var name in this.attributes)el.setAttribute(name,this.attributes[name]);return el}},{"./Rule":2}],4:[function(require,module,exports){/**
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jss=e()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports=require("./lib/index")},{"./lib/index":4}],2:[function(require,module,exports){"use strict";var uid=0;var processors=[];function Rule(selector,style,stylesheet){if(typeof selector=="object"){stylesheet=style;style=selector;selector=null}if(selector){this.selector=selector}else{this.className=Rule.NAMESPACE_PREFIX+"-"+uid;uid++;this.selector="."+this.className}this.stylesheet=stylesheet;this.style=style}module.exports=Rule;Rule.NAMESPACE_PREFIX="jss";Rule.addPreprocessor=function(fn){processors.push(fn);return processors};Rule.prototype.runPreprocessors=function(){for(var i=0;i<processors.length;i++){processors[i](this)}return this};var hasKeyframes=/@keyframes/;Rule.prototype.toString=function(){var isKeyframe=hasKeyframes.test(this.selector);var style=this.style;var str=this.selector+" {";for(var prop in style){var value=style[prop];if(typeof value=="object"){var valueStr="{";for(var prop2 in value){valueStr+="\n "+prop2+": "+value[prop2]+";"}valueStr+="\n }";value=valueStr}else{value+=";"}str+="\n "+prop+(isKeyframe?" ":": ")+value}str+="\n}";return str}},{}],3:[function(require,module,exports){"use strict";var Rule=require("./Rule");function Stylesheet(rules,named,attributes){if(typeof named=="object"){attributes=named;named=false}this.element=null;this.attached=false;this.named=named||false;this.rules={};this.attributes=attributes||{};this.classes={};this.text="";if(!this.attributes.type)this.attributes.type="text/css";if(!this.attributes.media)this.attributes.media="screen";this.element=this.createElement();if(rules)this.createRules(rules)}module.exports=Stylesheet;Stylesheet.prototype.attach=function(){if(this.attached)return this;if(!this.text){this.text=this.toString();this.element.innerHTML="\n"+this.text+"\n"}document.head.appendChild(this.element);this.attached=true;return this};Stylesheet.prototype.detach=function(){if(!this.attached)return this;this.element.parentNode.removeChild(this.element);this.attached=false;return this};Stylesheet.prototype.addRule=function(key,style){var rule=this.createRule(key,style);var sheet=this.element.sheet;sheet.insertRule(rule.toString(),sheet.cssRules.length);return rule};Stylesheet.prototype.addRules=function(rules){for(var key in rules){this.addRule(key,rules[key])}return this};Stylesheet.prototype.getRule=function(key){return this.rules[key]};Stylesheet.prototype.toString=function(){var str="";var rules=this.rules;for(var key in rules){if(str)str+="\n";str+=rules[key].toString()}return str};Stylesheet.prototype.createRule=function(key,style){var selector,name;if(this.named)name=key;else selector=key;var rule=new Rule(selector,style,this);this.rules[name||rule.selector]=rule;if(this.named)this.classes[name]=rule.className;rule.runPreprocessors();return rule};Stylesheet.prototype.createRules=function(rules){for(var key in rules){this.createRule(key,rules[key])}return this};Stylesheet.prototype.createElement=function(){var el=document.createElement("style");for(var name in this.attributes)el.setAttribute(name,this.attributes[name]);return el}},{"./Rule":2}],4:[function(require,module,exports){/**
* Stylesheets written in javascript.

@@ -8,2 +8,2 @@ *

*/
"use strict";var Stylesheet=require("./Stylesheet");var Rule=require("./Rule");[require("./processors/nested"),require("./processors/extend")].forEach(Rule.addPreprocessor);exports.Stylesheet=Stylesheet;exports.Rule=Rule;exports.createStylesheet=function(rules,named,attributes){return new Stylesheet(rules,named,attributes)};exports.createRule=function(selector,style){return new Rule(selector,style)}},{"./Rule":2,"./Stylesheet":3,"./processors/extend":5,"./processors/nested":6}],5:[function(require,module,exports){"use strict";module.exports=function(rule){var style=rule.style;if(!style)return;var extend=style.extend;if(!extend)return;var newStyle={};var prop;if("length"in extend){for(var i=0;i<extend.length;i++){for(prop in extend[i])newStyle[prop]=extend[i][prop]}}else{for(prop in extend)newStyle[prop]=extend[prop]}for(prop in style){if(prop!="extend")newStyle[prop]=style[prop]}rule.style=newStyle}},{}],6:[function(require,module,exports){"use strict";var Rule=require("../Rule");module.exports=function(rule){var stylesheet=rule.stylesheet;var style=rule.style;for(var prop in style){if(prop[0]=="&"){var selector=prop.replace(/&/gi,rule.selector);stylesheet.rules[selector]=new Rule(selector,style[prop],stylesheet);delete style[prop]}}}},{"../Rule":2}]},{},[1])(1)});
"use strict";var Stylesheet=require("./Stylesheet");var Rule=require("./Rule");[require("./processors/nested"),require("./processors/extend")].forEach(Rule.addPreprocessor);exports.Stylesheet=Stylesheet;exports.Rule=Rule;exports.createStylesheet=function(rules,named,attributes){return new Stylesheet(rules,named,attributes)};exports.createRule=function(selector,style){return new Rule(selector,style)}},{"./Rule":2,"./Stylesheet":3,"./processors/extend":5,"./processors/nested":6}],5:[function(require,module,exports){"use strict";var toString=Object.prototype.toString;module.exports=function(rule){var style=rule.style;if(!style||!style.extend)return;var newStyle={};(function extend(style){if(toString.call(style.extend)=="[object Array]"){for(var i=0;i<style.extend.length;i++){extend(style.extend[i])}}else{for(var prop in style.extend){if(prop=="extend")extend(style.extend.extend);else newStyle[prop]=style.extend[prop]}}for(var prop in style){if(prop!="extend")newStyle[prop]=style[prop]}})(style);rule.style=newStyle}},{}],6:[function(require,module,exports){"use strict";var Rule=require("../Rule");module.exports=function(rule){var stylesheet=rule.stylesheet;var style=rule.style;for(var prop in style){if(prop[0]=="&"){var selector=prop.replace(/&/gi,rule.selector);stylesheet.rules[selector]=new Rule(selector,style[prop],stylesheet);delete style[prop]}}}},{"../Rule":2}]},{},[1])(1)});

@@ -157,3 +157,2 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

if (!this.attributes.media) this.attributes.media = 'screen'
if (!this.attributes.title) this.attributes.title = 'Generated by jss.'
this.element = this.createElement()

@@ -364,2 +363,4 @@

var toString = Object.prototype.toString
/**

@@ -374,25 +375,24 @@ * Handle `extend` property.

if (!style) return
if (!style || !style.extend) return
var extend = style.extend
if (!extend) return
var newStyle = {}
var prop
// Copy extend style.
if ('length' in extend) {
for (var i = 0; i < extend.length; i++) {
for (prop in extend[i]) newStyle[prop] = extend[i][prop]
;(function extend(style) {
if (toString.call(style.extend) == '[object Array]') {
for (var i = 0; i < style.extend.length; i++) {
extend(style.extend[i])
}
} else {
for (var prop in style.extend) {
if (prop == 'extend') extend(style.extend.extend)
else newStyle[prop] = style.extend[prop]
}
}
} else {
for (prop in extend) newStyle[prop] = extend[prop]
}
// Copy base style.
for (var prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}
}(style))
// Copy original style.
for (prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}

@@ -399,0 +399,0 @@ rule.style = newStyle

@@ -0,1 +1,6 @@

## 0.2.10 / 2014-11-10
- support nested extend
- add more complex topcoat example
## 0.2.9 / 2014-11-03

@@ -2,0 +7,0 @@

'use strict'
var toString = Object.prototype.toString
/**

@@ -12,27 +14,26 @@ * Handle `extend` property.

if (!style) return
if (!style || !style.extend) return
var extend = style.extend
if (!extend) return
var newStyle = {}
var prop
// Copy extend style.
if ('length' in extend) {
for (var i = 0; i < extend.length; i++) {
for (prop in extend[i]) newStyle[prop] = extend[i][prop]
;(function extend(style) {
if (toString.call(style.extend) == '[object Array]') {
for (var i = 0; i < style.extend.length; i++) {
extend(style.extend[i])
}
} else {
for (var prop in style.extend) {
if (prop == 'extend') extend(style.extend.extend)
else newStyle[prop] = style.extend[prop]
}
}
} else {
for (prop in extend) newStyle[prop] = extend[prop]
}
// Copy base style.
for (var prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}
}(style))
// Copy original style.
for (prop in style) {
if (prop != 'extend') newStyle[prop] = style[prop]
}
rule.style = newStyle
}

@@ -27,3 +27,2 @@ 'use strict'

if (!this.attributes.media) this.attributes.media = 'screen'
if (!this.attributes.title) this.attributes.title = 'Generated by jss.'
this.element = this.createElement()

@@ -30,0 +29,0 @@

{
"name": "jss",
"description": "Dynamic stylesheets for web components.",
"version": "0.2.9",
"version": "0.2.10",
"author": {

@@ -6,0 +6,0 @@ "name": "Oleg Slobodskoi",

@@ -117,3 +117,3 @@ ## Dynamic stylesheets for web components.

```css
<style type="text/css" media="print" title="Generated by jss.">
<style type="text/css" media="print">
.selector {

@@ -139,3 +139,3 @@ width: 100px;

```css
<style type="text/css" media="screen" title="Generated by jss.">
<style type="text/css" media="screen">
.jss-0 {

@@ -142,0 +142,0 @@ width: 100px;

@@ -29,1 +29,14 @@ QUnit.module('Extend preprocessor')

})
test('nested extend', function () {
var c = {float: 'left'}
var b = {extend: c, display: 'none'}
var ss = new jss.Stylesheet({
a: {
extend: b,
width: '1px'
}
})
ok(ss.rules.a instanceof jss.Rule)
equal(ss.toString(), 'a {\n float: left;\n display: none;\n width: 1px;\n}')
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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