The goal of this project is to serve as a stable and efficient base for many css polyfills.
To make this objective a working thing, the project is divided into modules which can be loaded on demand.
This documentation is only a beginning, please feel free to improve it while you discover new useful things. Please note this file is automatically generated from the typescript files in this folder, so please edit those files, and run "grunt concat:doc" to update this one.
Provides an easier way to deal with the different css style objects of an element.
var cssBox = require('core:css-box');
var box = cssBox.getBox(document.body, 'border-box');
return { top: box.top, left: box.left, right: box.left+box.width, bottom: box.top+box.height };
var cssBox = require('core:css-box');
var box = cssBox.getBox(document.body, 'content-box');
return { top: box.top, left: box.left, right: box.left+box.width, bottom: box.top+box.height };
return ["content-box", "padding-box", "border-box", "margin-box"];
Provide helpers to interact with or simulate the css cascading engine.
var cssCascade = require('core:css-cascade');
cssCascade.startMonitoringProperties(
["-css-grid", "-css-grid-row", "css-grid-col"],
{
onupdate: function(element, rule) {
// TODO: update the layout of "element"
}
}
);
var cssCascade = require('core:css-cascade');
return cssCascade.getSpecifiedStyle(document.body, 'poly-grid')
var cssCascade = require('core:css-cascade');
var rules = cssCascade.findAllMatchingRules(document.body);
var row = cssCascade.getSpecifiedStyle(document.body, 'poly-grid-row', rules);
var col = cssCascade.getSpecifiedStyle(document.body, 'poly-grid-col', rules);
return [row, col];
var cssCascade = require('core:css-cascade');
cssCascade.polyfillStyleInterface('poly-grid');
var cssStyle = require('core:css-style').valueOf();
var style = cssStyle.usedStyleOf(document.body);
return style.polyGrid;
// BEFORE LOADING THE POLYFILL:
window['no_auto_stylesheet_detection'] = true;
// AFTER LOADING THE POLYFILL:
var cssCascade = require('core:css-cascade');
cssCascade.loadStyleSheet("* { color: red; }");
cssCascade.loadStyleSheetTag(document.querySelector('style.polyfill').valueOf());
Provides a way to obtain some intrinsic size info out of displayed HTML Elements.
var cssSizing = require('core:css-sizing');
var min = cssSizing.minWidthOf(document.body);
var max = cssSizing.maxWidthOf(document.body);
return [min, max];
Provides an easier way to deal with the different css style objects of an element.
var cssStyle = require('core:css-style');
return cssStyle.usedStyleOf(document.body).alignContent;
var cssStyle = require('core:css-style');
// set the runtime style
var backup = cssStyle.enforceStyle(document.body, "color", "red");
// reset the previous value
cssStyle.restoreStyle(document.body, backup);
Provides a "css-syntax-3" css parser.
var cssSyntax = require('core:css-syntax');
return cssSyntax.tokenize("* { color: red; }");
var cssSyntax = require('core:css-syntax');
return cssSyntax.parse("* { color: red; }");
var cssSyntax = require('core:css-syntax');
return cssSyntax.parseCSSValue("url('bg.png')");
Provides a basic css unit converter.
var cssUnits = require('core:css-units');
return cssUnits.convertToPixels("33%", document.body, {
boxType: "content-box",
isHeightRelated: true
});
var cssUnits = require('core:css-units');
return cssUnits.convertFromPixels(550/*px*/, /*to*/"em", document.body, {
boxType: "content-box",
isHeightRelated: true
});
Provides helpers for dealing with events in your code.
function SomeObject() {
// init a new SomeObject
}
var domEvents = require('core:dom-events');
domEvents.EventTarget.implementsIn(SomeObject);
var domEvents = require('core:dom-events');
document.body.onclick = function(e) {
// do as if we just clicked on #some-element instead
var someEvent = domEvents.cloneEvent(e);
var someElement = document.querySelector("#some-element");
someElement.dispatchEvent(someEvent);
};