stylesheet.html revision b0cfaf8e62a833866fd861fe7ff60747ba997be0
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay <link type="text/css" rel="stylesheet" href="/assets/dpSyntaxHighlighter.css">
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay <link type="text/css" id="locallink" rel="stylesheet" href="/build/test/assets/test-console.css">
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay <style type="text/css" id="styleblock" class="highlight-ignore">
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay font: normal 125%/1.4 Arial, sans-serif;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .yui-skin-sam .yui-console .yui-console-content {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay font-size: 10px;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay width: 32em;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .yui-skin-sam .yui-console .yui-console-bd {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay height: 50em;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .yui-skin-sam .yui-console-entry-pass .yui-console-entry-cat {
774e588adf3161d97e13816b71219a2d4e3335a8chad.kienle background: #070;
774e588adf3161d97e13816b71219a2d4e3335a8chad.kienle color: #fff;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .yui-skin-sam .yui-console-entry-fail .yui-console-entry-cat {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay background: #700;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay color: #fff;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .highlight-example {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay display: inline;
21dcdac963f79c098a5ea1a2c5c5e109429c9786Brendan Miller width: 650px;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .highlight-example h2 {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay display: none;
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay .yui-skin-sam .yui-console-entry-time {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay display: none;
e435bd6f4bb55de339fe53b592ee9c8fd75a23b6Brendan Miller<script type="text/javascript" src="/build/yui/yui.js"></script>
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay<script type="text/javascript" src="/build/dom/dom.js"></script>
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay<script type="text/javascript" src="/build/console/console-debug.js"></script>
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay<script type="text/javascript" src="/build/stylesheet/stylesheet-debug.js"></script>
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay<script type="text/javascript" src="/build/test/test-debug.js"></script>
774e588adf3161d97e13816b71219a2d4e3335a8chad.kienle filter : 'debug',
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay useBrowserConsole : false,
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay logInclude : { TestRunner: true, stylesheet: true }
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay}).use('test','console','stylesheet',function (Y) {
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemayvar d = document,
774e588adf3161d97e13816b71219a2d4e3335a8chad.kienle suite = new Y.Test.Suite("StyleSheet Tests"),
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay StyleAssert = {},
e86d0731d2d88f053f4f50ebc7060346a3f7934dJason Lemay 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);