Skip to content

Commit

Permalink
check for prefixed hyphens property
Browse files Browse the repository at this point in the history
  • Loading branch information
mnater committed May 30, 2018
1 parent 4453428 commit 971d523
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Hyphenopoly_Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,20 @@
};
}());

/**
* Checks if hyphens (ev.prefixed) is set to auto for the element.
* @param {Object} el - the element
* @returns {Boolean} result of the check
*/
function checkCSSHyphensSupport(el) {
const computedStyle = window.getComputedStyle(el);
const supp = computedStyle.hyphens === "auto" ||
computedStyle["-webkit-hyphens"] === "auto" ||
computedStyle["-ms-hyphens"] === "auto" ||
computedStyle["-moz-hyphens"] === "auto";
return supp;
}

Object.keys(H.require).forEach(function doReqLangs(lang) {
if (H.require[lang] === "FORCEHYPHENOPOLY") {
t.polyfill = true;
Expand All @@ -442,8 +456,7 @@
Object.keys(H.require).forEach(function checkReqLangs(lang) {
if (H.require[lang] !== "FORCEHYPHENOPOLY") {
const el = d.getElementById(lang);
if (window.getComputedStyle(el).hyphens === "auto" &&
el.offsetHeight > 12) {
if (checkCSSHyphensSupport(el) && el.offsetHeight > 12) {
t.polyfill = t.polyfill || false;
t.langs[lang] = "CSS";
} else {
Expand Down

0 comments on commit 971d523

Please sign in to comment.