can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
50 lines (48 loc) • 1.41 kB
HTML
<html>
<head>
<title>testing dom-style</title>
<style type="text/css">
@import "../resources/dojo.css";
.nodeStyle
{
padding: 1px 2px 3px 4px;
}
</style>
<script type="text/javascript" src="../dojo.js" data-dojo-config="isDebug:true"></script>
<script type="text/javascript">
require(["dojo", "doh", "dojo/dom-style", "dojo/dom", "dojo/domReady!"], function(dojo, doh, domStyle, dom){
doh.register([
{
name: "getComputedStyle",
runTest: function(t){
try {
var node = dom.byId('node'),
s = domStyle.getComputedStyle(node);
doh.t(s !== null);
// Create a node on the fly,
// IE < 9 has issue with currentStyle when creating elements on the fly.
node = document.createElement('div');
domStyle.set(node, 'nodeStyle');
s = domStyle.getComputedStyle(node);
doh.t(s !== null);
} catch (err) {
console.error(err);
doh.t(false);
}
}
},
function getWidth(){
// see http://bugs.dojotoolkit.org/ticket/17962
var rowWidth = domStyle.get(dom.byId("trow"), "width");
doh.t(rowWidth > 0, "width: " + rowWidth);
}
]);
doh.run();
});
</script>
</head>
<body>
<div id="node" style="padding: 1px 2px 3px 4px;"></div>
<table><tbody><tr id="trow"><td>Col A</td><td>Col B</td></tr></tbody></table>
</body>
</html>