Write the CSS serially in order to remove async loading
This commit is contained in:
@@ -1,25 +1,27 @@
|
|||||||
|
|
||||||
function setupIframe(callback) {
|
|
||||||
|
var iframe = (function() {
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
var doc = iframe.contentDocument;
|
var doc = iframe.contentDocument;
|
||||||
|
|
||||||
var link = document.createElement('link');
|
var style = document.createElement('style');
|
||||||
link.setAttribute('rel', 'stylesheet');
|
style.innerText = (function() {/*
|
||||||
link.setAttribute('type', 'text/css');
|
body, div {
|
||||||
link.setAttribute('href', 'style.css');
|
box-sizing: border-box;
|
||||||
doc.head.appendChild(link);
|
|
||||||
|
|
||||||
requestAnimationFrame(function wait() {
|
display: flex;
|
||||||
if (doc.styleSheets.length) {
|
flex-direction: column;
|
||||||
callback(iframe);
|
align-items: flex-start;
|
||||||
} else {
|
|
||||||
requestAnimationFrame(wait);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var iframe = null;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
*/} + '').slice(15, -4);
|
||||||
|
doc.head.appendChild(style);
|
||||||
|
|
||||||
|
return iframe;
|
||||||
|
})();
|
||||||
|
|
||||||
function computeDOMLayout(node) {
|
function computeDOMLayout(node) {
|
||||||
var body = iframe.contentDocument.body;
|
var body = iframe.contentDocument.body;
|
||||||
@@ -97,14 +99,6 @@ function testLayout(node, expectedLayout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Layout', function() {
|
describe('Layout', function() {
|
||||||
beforeEach(function(done) {
|
|
||||||
if (iframe) {
|
|
||||||
done();
|
|
||||||
} else {
|
|
||||||
setupIframe(function(ifrm) { iframe = ifrm; done(); });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should layout a single node with width and height', function() {
|
it('should layout a single node with width and height', function() {
|
||||||
testLayout({
|
testLayout({
|
||||||
style: {width: 100, height: 200}
|
style: {width: 100, height: 200}
|
||||||
@@ -474,7 +468,6 @@ describe('Layout', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should layout randomly', function() {
|
it('should layout randomly', function() {
|
||||||
function RNG(seed) {
|
function RNG(seed) {
|
||||||
this.state = seed;
|
this.state = seed;
|
||||||
|
Reference in New Issue
Block a user