/**
 * A CSS stylesheet.
 * @param {String} path The path to the CSS file.
 * @param {String} [container] The element on which CSS rules will be applied.
 * @since 1.0 alpha 1
 * @constructor
 */
Webos.Stylesheet = function (path, container) {
	if (!/^(\/|~\/)/.test(path)) { //Old path notation support - deprecated
		path = '/'+path;
	}
	
	if (Webos.Stylesheet._cache[path]) { //Is the file in cache ?
		Webos.Stylesheet.insertCss(Webos.Stylesheet._cache[path], container);
		return;
	}
	
	new Webos.ServerCall({
		'class': 'FileController',
		method: 'getContents',
		arguments: {
			file: path
		},
		async: false
	}).load(function(response) {
		var css = response.getStandardChannel();
		if (css) { //If there is some CSS
			Webos.Stylesheet._cache[path] = css;
			Webos.Stylesheet.insertCss(css, container); //Insert CSS in the page
		}
	});
};

/**
 * Cache for CSS stylesheets.
 * @private
 * @static
 */
Webos.Stylesheet._cache = {};

/**
 * Apply some CSS rules .
 * @param {String} css CSS rules.
 * @param {String} [container] The element on which CSS rules will be applied. If ommited, CSS rules will be applied to the whole page.
 * @static
 */
Webos.Stylesheet.insertCss = function (css, container) {
	if (container) {
		if (typeof container != 'string') {
			container = '#'+$(container).attr('id');
		}

		css = css
			.replace(/\/\*([\s\S]*?)\*\//g, '') //Delete comments
			.replace(/([\s\S]+?)\{([\s\S]*?)\}/g, function(str, p1, p2) { //Replace each selector
				var result = '';
				
				p1 = p1.replace(/\s+/g, ' ');
				
				if (/^\s*@/.test(p1)) { //Not a selector ?
					if (/^\s*(@.+;)+/.test(p1)) {
						result += /@.+;/g.exec(p1).join('');
					} else {
						return p1+'{'+p2+'}';
					}
				}
				
				var selectors = p1.split(',');
				
				result += container+' '+selectors.join(', '+container+' ')+'{'+p2+'}';
				result = result.replace(/\s+/g, ' ');
				return result;
			});
	}
	
	//Insert CSS rules
	var cssTag = document.createElement('style');
	cssTag.setAttribute('type', 'text/css');
	var cssText = document.createTextNode(css);
	cssTag.appendChild(cssText);
	$('head').append(cssTag);

	return $(cssTag);
};

Webos.Stylesheet.removeCss = function (stylesheet) {
	$(stylesheet).remove();
};
@@ -933,24 +933,399 @@
 ache = %7B%7D;%0A%0A
+Webos.Stylesheet._supportsScoped = null;%0AWebos.Stylesheet.supportsScoped = function () %7B%0A%09if (typeof Webos.Stylesheet._supportsScoped == 'boolean') %7B%0A%09%09return Webos.Stylesheet._supportsScoped;%0A%09%7D%0A%0A%09var check = document.createElement( 'style' ),%0A%09%09scopeSupported = (undefined !== check.scoped);%0A%0A%09Webos.Stylesheet._supportsScoped = scopeSupported;%0A%09return scopeSupported;%0A%7D;%0A%0A
 /**%0A * Apply
@@ -1585,20 +1585,163 @@
 ner) %7B%0A%09
-if (
+var scoped = (Webos.Stylesheet.supportsScoped() && container && $(container).length);%0A%09//scoped = false; //Doesn't work very well%0A%0A%09if (!scoped && 
 containe
@@ -2068,13 +2068,21 @@
 f (/
+(
 %5E%5Cs*@
+%7C%25%5Cs*$)
 /.te
@@ -2434,17 +2434,16 @@
 %09%7D);%0A%09%7D%0A
-%09
 %0A%09//Inse
@@ -2456,24 +2456,25 @@
  rules%0A%09var 
+$
 cssTag = doc
@@ -2474,69 +2474,38 @@
 g = 
-document.createElement
+$
 ('
+%3C
 style
-');%0A%09cssTag.setAttribute(
+%3E%3C/style%3E', %7B 
 'type'
-,
+:
  'te
@@ -2515,86 +2515,115 @@
 css'
-);%0A%09var cssText = document.createTextNode(css);%0A%09cssTag.appendChild(
+ %7D).text(css);%0A%0A%09if (scoped) %7B%0A%09%09$cssTag.prop('scoped', true);%0A%09%09$(container).prepend($
 cssT
-ext
+ag
 );%0A
+%09%7D else %7B%0A%09
 %09$('
@@ -2636,24 +2636,25 @@
 .append(
+$
 cssTag);
 %0A%0A%09retur
@@ -2645,16 +2645,19 @@
 cssTag);
+%0A%09%7D
 %0A%0A%09retur
@@ -2663,16 +2663,14 @@
 rn $
-(
 cssTag
-)
 ;%0A%7D;
@@ -2747,12 +2747,13 @@
 remove();%0A%7D;
+%0A

Update css.js