stylesheet.html revision 1fd79b116af4fdf76948c0e0ed8bb3ae47955e70
2fdf8d4f1ad797aaf0bfd3af88e4c04402b9ce3bMatt Sweeney <link type="text/css" id="locallink" rel="stylesheet" href="/build/test/assets/test-console.css">
2fdf8d4f1ad797aaf0bfd3af88e4c04402b9ce3bMatt Sweeney <style type="text/css" id="styleblock" class="highlight-ignore">
2fdea3dd40cb6e0b382e7c0387a76f5290cadd27Luke Smith font: normal 125%/1.4 Arial, sans-serif;
2fdf8d4f1ad797aaf0bfd3af88e4c04402b9ce3bMatt Sweeney .yui-skin-sam .yui-console .yui-console-content {
feb1dc670b0d4e1c6fcff58b35b36da3dfc5f18cJenny Donnelly font-size: 10px;
feb1dc670b0d4e1c6fcff58b35b36da3dfc5f18cJenny Donnelly .yui-skin-sam .yui-console .yui-console-bd {
feb1dc670b0d4e1c6fcff58b35b36da3dfc5f18cJenny Donnelly height: 50em;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney .yui-skin-sam .yui-console-entry-pass .yui-console-entry-cat {
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney background: #070;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney .yui-skin-sam .yui-console-entry-fail .yui-console-entry-cat {
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney background: #700;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney color: #fff;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney .highlight-example {
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney display: inline;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney float: left;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney width: 650px;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney .highlight-example h2 {
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney display: none;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney .yui-skin-sam .yui-console-entry-time {
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney display: none;
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney<script type="text/javascript" src="/build/yui/yui.js"></script>
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney filter : 'raw',
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney stylesheet: 'debug'
feb1dc670b0d4e1c6fcff58b35b36da3dfc5f18cJenny Donnelly logInclude : { TestRunner: true, stylesheet: true }
93298460d1839a963f1f5979e90ee59dccf5b855Matt Sweeney}).use('test','console','stylesheet',function (Y) {
Assert = Y.Assert,
StyleSheet = Y.StyleSheet,
suite = new Y.Test.Suite("StyleSheet Tests"),
testbed = d.getElementById('testbed');
StyleAssert.normalizeColor = function (c) {
StyleAssert.areEqual = function (a,b,msg) {
var aa = StyleAssert.normalizeColor(a),
bb = StyleAssert.normalizeColor(b);
throw new Assert.ComparisonFailure(
Dom.add = function (el,tag,conf) {
var child = d.createElement(tag);
Y.mix(child,conf,true);
return el.appendChild(child);
Dom.getNodeCount = function (tag,root) {
Dom.getSheet = function (yuid) {
var nodes = d.getElementsByTagName('style'),
for (i = nodes.length - 1; i >= 0; --i) {
testbed.innerHTML = '';
Assert.areSame(a,b,"From cache by name");
b = new StyleSheet(a.getId());
Assert.areSame(a,b,"From cache by yuiSSID");
a = new StyleSheet(d.getElementById('styleblock'));
Assert.areSame(a,b,"From cache by node vs id");
d.getElementsByTagName('head')[0],'link',{
sheet.set('#target', { color: '#f00' });
sheet.unset('#target', 'color');
sheet.enable();
this.stylesheet = new StyleSheet('test');
testbed.innerHTML = '';
this.stylesheet.unset('#target');
this.stylesheet.unset('#target p');
this.stylesheet.unset('#target pre');
this.stylesheet.unset('#target, #target p, #target pre');
this.stylesheet.set('#target',{
StyleAssert.areEqual('#123456',
StyleAssert.areEqual('#eef',
StyleAssert.areEqual('1px',
this.stylesheet.set('#target .foo .bar', { color : 'invalid-value' });
var before = Y.DOM.getStyle(
testbed.getElementsByTagName('pre')[0],'textAlign');
this.stylesheet.set('#target p', { textAlign: 'right' });
StyleAssert.areEqual('right',
testbed.getElementsByTagName('p')[0],'textAlign'),
StyleAssert.areEqual(before,
testbed.getElementsByTagName('pre')[0],'textAlign'),
Assert.fail("Could not find this StyleSheet's node or sheet");
this.stylesheet.set('#target, #target p, #target pre', {
StyleAssert.areEqual('16px',
testbed.getElementsByTagName('p')[0],'paddingLeft'),
StyleAssert.areEqual('16px',
testbed.getElementsByTagName('pre')[0],'paddingLeft'),
this.stylesheet = new StyleSheet('test');
this.before = {
testbed.innerHTML = '';
this.stylesheet.unset('#target');
this.stylesheet.unset('#target p');
this.stylesheet.set('#target',{
StyleAssert.areEqual('#123456',
StyleAssert.areEqual('#eef',
StyleAssert.areEqual('1px',
this.stylesheet.set('#target',{
StyleAssert.areEqual('#123456',
StyleAssert.areEqual('#eef',
StyleAssert.areEqual('1px',
this.stylesheet = new StyleSheet('test');
this.before = {
testbed.innerHTML = '';
this.stylesheet.unset('#target');
this.stylesheet.unset('#target p');
this.stylesheet.unset('#target pre');
this.stylesheet.unset('#target, #target p, #target pre');
this.stylesheet.set('#target',{
StyleAssert.areEqual('#f00',
StyleAssert.areEqual('#eef',
StyleAssert.areEqual('1px',
this.stylesheet.unset('#target', 'color');
this.stylesheet.unset('#target', ['backgroundColor','border']);
this.stylesheet.set('#target', { textAlign: 'right' });
StyleAssert.areEqual('right',
this.stylesheet.unset('#target');
var p = this.testNode.getElementsByTagName('p')[0],
pre = this.testNode.getElementsByTagName('pre')[0],
Y.DOM.getStyle(p,'paddingLeft'),
Y.DOM.getStyle(pre,'paddingLeft')
Y.DOM.getStyle(p,'marginRight'),
Y.DOM.getStyle(pre,'marginRight')
Assert.fail("Could not find this StyleSheet's node or sheet");
this.stylesheet.set('#target, #target p, #target pre', {
this.stylesheet.unset('#target, #target p, #target pre','paddingLeft');
Y.DOM.getStyle(p,'paddingLeft'),
Y.DOM.getStyle(pre,'paddingLeft')
Y.DOM.getStyle(p,'marginRight'),
Y.DOM.getStyle(pre,'marginRight')
Y.ArrayAssert.itemsAreEqual(['30px','30px','30px'],after);
var p = this.testNode.getElementsByTagName('p')[0],
pre = this.testNode.getElementsByTagName('pre')[0],
Y.DOM.getStyle(p,'paddingLeft'),
Y.DOM.getStyle(pre,'paddingLeft')
Assert.fail("Could not capture this StyleSheet's node or sheet");
this.stylesheet.set('#target, #target p, #target pre', {
this.stylesheet.unset('#target, #target pre','paddingLeft');
this.stylesheet = new StyleSheet('test');
this.stylesheet.set('#target, #target p', {
testbed.innerHTML = '';
this.stylesheet.unset('#target');
this.stylesheet.unset('#target p');
var css = this.stylesheet.getCssText('#target p');
Y.log(css, 'info','TestLogger');
Assert.isString(css);
var css = this.stylesheet.getCssText();
Y.log(css, 'info','TestLogger');
Assert.isString(css);
this.stylesheet = new StyleSheet('test');
if (!d.getElementById('target')) {
var p1 = Y.DOM.byId('p1'),
p2 = Y.DOM.byId('p2'),
p3 = Y.DOM.byId('p3');
this.stylesheet.set('#target',{
var p1 = Y.DOM.byId('p1'),
p2 = Y.DOM.byId('p2'),
p3 = Y.DOM.byId('p3');
this.stylesheet.set('#p1',{ opacity: .5 }).
var yconsole = new Y.Console({
//yconsole.hideCategory('info');
Y.Test.Runner.add(suite);