Release 5.1.0 (#1135)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Font Awesome Pro 5.0.13 by @fontawesome - https://fontawesome.com
|
||||
* Font Awesome Pro 5.1.0 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license (Commercial License)
|
||||
*/
|
||||
(function () {
|
||||
@@ -37,8 +37,10 @@ var DEFAULT_FAMILY_PREFIX = 'fa';
|
||||
var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
|
||||
var DATA_FA_I2SVG = 'data-fa-i2svg';
|
||||
var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
|
||||
var DATA_PREFIX = 'data-prefix';
|
||||
var DATA_ICON = 'data-icon';
|
||||
var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
|
||||
|
||||
var TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS = ['HTML', 'HEAD', 'STYLE', 'SCRIPT'];
|
||||
var PRODUCTION = function () {
|
||||
try {
|
||||
return undefined === 'production';
|
||||
@@ -100,6 +102,44 @@ var _extends = Object.assign || function (target) {
|
||||
|
||||
|
||||
|
||||
var slicedToArray = function () {
|
||||
function sliceIterator(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"]) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
return function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator(arr, i);
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
var toConsumableArray = function (arr) {
|
||||
if (Array.isArray(arr)) {
|
||||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
||||
@@ -111,7 +151,40 @@ var toConsumableArray = function (arr) {
|
||||
};
|
||||
|
||||
var initial = WINDOW.FontAwesomeConfig || {};
|
||||
var initialKeys = Object.keys(initial);
|
||||
|
||||
function getAttrConfig(attr) {
|
||||
var element = DOCUMENT.querySelector('script[' + attr + ']');
|
||||
|
||||
if (element) {
|
||||
return element.getAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
function coerce(val) {
|
||||
// Getting an empty string will occur if the attribute is set on the HTML tag but without a value
|
||||
// We'll assume that this is an indication that it should be toggled to true
|
||||
// For example <script data-search-pseudo-elements src="..."></script>
|
||||
if (val === '') return true;
|
||||
if (val === 'false') return false;
|
||||
if (val === 'true') return true;
|
||||
return val;
|
||||
}
|
||||
|
||||
if (DOCUMENT && typeof DOCUMENT.querySelector === 'function') {
|
||||
var attrs = [['data-family-prefix', 'familyPrefix'], ['data-replacement-class', 'replacementClass'], ['data-auto-replace-svg', 'autoReplaceSvg'], ['data-auto-add-css', 'autoAddCss'], ['data-auto-a11y', 'autoA11y'], ['data-search-pseudo-elements', 'searchPseudoElements'], ['data-observe-mutations', 'observeMutations'], ['data-keep-original-source', 'keepOriginalSource'], ['data-measure-performance', 'measurePerformance'], ['data-show-missing-icons', 'showMissingIcons']];
|
||||
|
||||
attrs.forEach(function (_ref) {
|
||||
var _ref2 = slicedToArray(_ref, 2),
|
||||
attr = _ref2[0],
|
||||
key = _ref2[1];
|
||||
|
||||
var val = coerce(getAttrConfig(attr));
|
||||
|
||||
if (val !== undefined && val !== null) {
|
||||
initial[key] = val;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var _default = _extends({
|
||||
familyPrefix: DEFAULT_FAMILY_PREFIX,
|
||||
@@ -132,30 +205,6 @@ var config = _extends({}, _default);
|
||||
|
||||
WINDOW.FontAwesomeConfig = config;
|
||||
|
||||
function update(newConfig) {
|
||||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _params$asNewDefault = params.asNewDefault,
|
||||
asNewDefault = _params$asNewDefault === undefined ? false : _params$asNewDefault;
|
||||
|
||||
var validKeys = Object.keys(config);
|
||||
var ok = asNewDefault ? function (k) {
|
||||
return ~validKeys.indexOf(k) && !~initialKeys.indexOf(k);
|
||||
} : function (k) {
|
||||
return ~validKeys.indexOf(k);
|
||||
};
|
||||
|
||||
Object.keys(newConfig).forEach(function (configKey) {
|
||||
if (ok(configKey)) config[configKey] = newConfig[configKey];
|
||||
});
|
||||
}
|
||||
|
||||
function auto(value) {
|
||||
update({
|
||||
autoReplaceSvg: value,
|
||||
observeMutations: value
|
||||
});
|
||||
}
|
||||
|
||||
var w = WINDOW || {};
|
||||
|
||||
if (!w[NAMESPACE_IDENTIFIER]) w[NAMESPACE_IDENTIFIER] = {};
|
||||
@@ -513,7 +562,9 @@ function makeInlineSvgAbstract(params) {
|
||||
height = _ref.height;
|
||||
|
||||
var widthClass = 'fa-w-' + Math.ceil(width / height * 16);
|
||||
var attrClass = [config.replacementClass, iconName ? config.familyPrefix + '-' + iconName : '', widthClass].concat(extra.classes).join(' ');
|
||||
var attrClass = [config.replacementClass, iconName ? config.familyPrefix + '-' + iconName : '', widthClass].filter(function (c) {
|
||||
return extra.classes.indexOf(c) === -1;
|
||||
}).concat(extra.classes).join(' ');
|
||||
|
||||
var content = {
|
||||
children: [],
|
||||
@@ -604,9 +655,40 @@ function makeLayersTextAbstract(params) {
|
||||
return val;
|
||||
}
|
||||
|
||||
function makeLayersCounterAbstract(params) {
|
||||
var content = params.content,
|
||||
title = params.title,
|
||||
extra = params.extra;
|
||||
|
||||
|
||||
var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, {
|
||||
'class': extra.classes.join(' ')
|
||||
});
|
||||
|
||||
var styleString = joinStyles(extra.styles);
|
||||
|
||||
if (styleString.length > 0) {
|
||||
attributes['style'] = styleString;
|
||||
}
|
||||
|
||||
var val = [];
|
||||
|
||||
val.push({
|
||||
tag: 'span',
|
||||
attributes: attributes,
|
||||
children: [content]
|
||||
});
|
||||
|
||||
if (title) {
|
||||
val.push({ tag: 'span', attributes: { class: 'sr-only' }, children: [title] });
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
var noop$2 = function noop() {};
|
||||
var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : { mark: noop$2, measure: noop$2 };
|
||||
var preamble = 'FA "5.0.13"';
|
||||
var preamble = 'FA "5.1.0"';
|
||||
|
||||
var begin = function begin(name) {
|
||||
p.mark(preamble + ' ' + name + ' begins');
|
||||
@@ -891,11 +973,19 @@ function disableObservation(operation) {
|
||||
var mo = null;
|
||||
|
||||
function observe(options) {
|
||||
if (!MUTATION_OBSERVER) return;
|
||||
if (!MUTATION_OBSERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.observeMutations) {
|
||||
return;
|
||||
}
|
||||
|
||||
var treeCallback = options.treeCallback,
|
||||
nodeCallback = options.nodeCallback,
|
||||
pseudoElementsCallback = options.pseudoElementsCallback;
|
||||
pseudoElementsCallback = options.pseudoElementsCallback,
|
||||
_options$observeMutat = options.observeMutationsRoot,
|
||||
observeMutationsRoot = _options$observeMutat === undefined ? DOCUMENT.body : _options$observeMutat;
|
||||
|
||||
|
||||
mo = new MUTATION_OBSERVER(function (objects) {
|
||||
@@ -931,7 +1021,7 @@ function observe(options) {
|
||||
|
||||
if (!IS_DOM) return;
|
||||
|
||||
mo.observe(DOCUMENT.getElementsByTagName('body')[0], {
|
||||
mo.observe(observeMutationsRoot, {
|
||||
childList: true, attributes: true, characterData: true, subtree: true
|
||||
});
|
||||
}
|
||||
@@ -1102,6 +1192,16 @@ var maskParser = function (node) {
|
||||
}
|
||||
};
|
||||
|
||||
var blankMeta = {
|
||||
iconName: null,
|
||||
title: null,
|
||||
prefix: null,
|
||||
transform: meaninglessTransform,
|
||||
symbol: false,
|
||||
mask: null,
|
||||
extra: { classes: [], styles: {}, attributes: {} }
|
||||
};
|
||||
|
||||
function parseMeta(node) {
|
||||
var _classParser = classParser(node),
|
||||
iconName = _classParser.iconName,
|
||||
@@ -1184,13 +1284,18 @@ var missing = { tag: 'g', children: [RING, DOT, QUESTION, EXCLAMATION] };
|
||||
var styles = namespace.styles;
|
||||
|
||||
var LAYERS_TEXT_CLASSNAME = 'fa-layers-text';
|
||||
var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands)/;
|
||||
var FONT_FAMILY_PATTERN = /Font Awesome 5 (Solid|Regular|Light|Brands|Free|Pro)/;
|
||||
var STYLE_TO_PREFIX = {
|
||||
'Solid': 'fas',
|
||||
'Regular': 'far',
|
||||
'Light': 'fal',
|
||||
'Brands': 'fab'
|
||||
};
|
||||
var FONT_WEIGHT_TO_PREFIX = {
|
||||
'900': 'fas',
|
||||
'400': 'far',
|
||||
'300': 'fal'
|
||||
};
|
||||
|
||||
function findIcon(iconName, prefix) {
|
||||
var val = {
|
||||
@@ -1286,47 +1391,67 @@ function generateMutation(node) {
|
||||
}
|
||||
}
|
||||
|
||||
function remove(node) {
|
||||
if (typeof node.remove === 'function') {
|
||||
node.remove();
|
||||
} else if (node && node.parentNode) {
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
function searchPseudoElements(root) {
|
||||
if (!IS_DOM) return;
|
||||
|
||||
var end = perf.begin('searchPseudoElements');
|
||||
|
||||
disableObservation(function () {
|
||||
toArray(root.querySelectorAll('*')).forEach(function (node) {
|
||||
toArray(root.querySelectorAll('*')).filter(function (n) {
|
||||
return n.parentNode !== document.head && !~TAGNAMES_TO_SKIP_FOR_PSEUDOELEMENTS.indexOf(n.tagName.toUpperCase()) && !n.getAttribute(DATA_FA_PSEUDO_ELEMENT) && (!n.parentNode || n.parentNode.tagName !== 'svg');
|
||||
}).forEach(function (node) {
|
||||
[':before', ':after'].forEach(function (pos) {
|
||||
var styles = WINDOW.getComputedStyle(node, pos);
|
||||
var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
|
||||
var children = toArray(node.children);
|
||||
var pseudoElement = children.filter(function (c) {
|
||||
var alreadyProcessedPseudoElement = children.filter(function (c) {
|
||||
return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === pos;
|
||||
})[0];
|
||||
|
||||
if (pseudoElement) {
|
||||
if (pseudoElement.nextSibling && pseudoElement.nextSibling.textContent.indexOf(DATA_FA_PSEUDO_ELEMENT) > -1) {
|
||||
remove(pseudoElement.nextSibling);
|
||||
}
|
||||
remove(pseudoElement);
|
||||
pseudoElement = null;
|
||||
}
|
||||
var styles = WINDOW.getComputedStyle(node, pos);
|
||||
var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
|
||||
var fontWeight = styles.getPropertyValue('font-weight');
|
||||
|
||||
if (fontFamily && !pseudoElement) {
|
||||
if (alreadyProcessedPseudoElement && !fontFamily) {
|
||||
// If we've already processed it but the current computed style does not result in a font-family,
|
||||
// that probably means that a class name that was previously present to make the icon has been
|
||||
// removed. So we now should delete the icon.
|
||||
node.removeChild(alreadyProcessedPseudoElement);
|
||||
} else if (fontFamily) {
|
||||
var content = styles.getPropertyValue('content');
|
||||
var i = DOCUMENT.createElement('i');
|
||||
i.setAttribute('class', '' + STYLE_TO_PREFIX[fontFamily[1]]);
|
||||
i.setAttribute(DATA_FA_PSEUDO_ELEMENT, pos);
|
||||
i.innerText = content.length === 3 ? content.substr(1, 1) : content;
|
||||
if (pos === ':before') {
|
||||
node.insertBefore(i, node.firstChild);
|
||||
} else {
|
||||
node.appendChild(i);
|
||||
var prefix = ~['Light', 'Regular', 'Solid'].indexOf(fontFamily[1]) ? STYLE_TO_PREFIX[fontFamily[1]] : FONT_WEIGHT_TO_PREFIX[fontWeight];
|
||||
var iconName = byUnicode(prefix, toHex(content.length === 3 ? content.substr(1, 1) : content));
|
||||
// Only convert the pseudo element in this :before/:after position into an icon if we haven't
|
||||
// already done so with the same prefix and iconName
|
||||
if (!alreadyProcessedPseudoElement || alreadyProcessedPseudoElement.getAttribute(DATA_PREFIX) !== prefix || alreadyProcessedPseudoElement.getAttribute(DATA_ICON) !== iconName) {
|
||||
if (alreadyProcessedPseudoElement) {
|
||||
// Delete the old one, since we're replacing it with a new one
|
||||
node.removeChild(alreadyProcessedPseudoElement);
|
||||
}
|
||||
|
||||
var extra = blankMeta.extra;
|
||||
|
||||
extra.attributes[DATA_FA_PSEUDO_ELEMENT] = pos;
|
||||
var abstract = makeInlineSvgAbstract(_extends({}, blankMeta, {
|
||||
icons: {
|
||||
main: findIcon(iconName, prefix),
|
||||
mask: emptyCanonicalIcon()
|
||||
},
|
||||
prefix: prefix,
|
||||
iconName: iconName,
|
||||
extra: extra,
|
||||
watchable: true
|
||||
}));
|
||||
|
||||
var element = DOCUMENT.createElement('svg');
|
||||
|
||||
if (pos === ':before') {
|
||||
node.insertBefore(element, node.firstChild);
|
||||
} else {
|
||||
node.appendChild(element);
|
||||
}
|
||||
|
||||
element.outerHTML = abstract.map(function (a) {
|
||||
return toHtml(a);
|
||||
}).join('\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1520,18 +1645,11 @@ function prepIcon(icon) {
|
||||
};
|
||||
}
|
||||
|
||||
var _cssInserted = false;
|
||||
|
||||
function ensureCss() {
|
||||
if (!config.autoAddCss) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_cssInserted) {
|
||||
if (config.autoAddCss && !_cssInserted) {
|
||||
insertCss(css());
|
||||
_cssInserted = true;
|
||||
}
|
||||
|
||||
_cssInserted = true;
|
||||
}
|
||||
|
||||
function apiObject(val, abstractCreator) {
|
||||
@@ -1591,10 +1709,14 @@ function resolveIcons(next) {
|
||||
var library = new Library();
|
||||
|
||||
var noAuto = function noAuto() {
|
||||
auto(false);
|
||||
config.autoReplaceSvg = false;
|
||||
config.observeMutations = false;
|
||||
|
||||
disconnect();
|
||||
};
|
||||
|
||||
var _cssInserted = false;
|
||||
|
||||
var dom = {
|
||||
i2svg: function i2svg() {
|
||||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
@@ -1619,7 +1741,36 @@ var dom = {
|
||||
css: css,
|
||||
|
||||
insertCss: function insertCss$$1() {
|
||||
insertCss(css());
|
||||
if (!_cssInserted) {
|
||||
insertCss(css());
|
||||
_cssInserted = true;
|
||||
}
|
||||
},
|
||||
|
||||
watch: function watch() {
|
||||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var autoReplaceSvgRoot = params.autoReplaceSvgRoot,
|
||||
observeMutationsRoot = params.observeMutationsRoot;
|
||||
|
||||
|
||||
if (config.autoReplaceSvg === false) {
|
||||
config.autoReplaceSvg = true;
|
||||
}
|
||||
|
||||
config.observeMutations = true;
|
||||
|
||||
domready(function () {
|
||||
autoReplace({
|
||||
autoReplaceSvgRoot: autoReplaceSvgRoot
|
||||
});
|
||||
|
||||
observe({
|
||||
treeCallback: onTree,
|
||||
nodeCallback: onNode,
|
||||
pseudoElementsCallback: searchPseudoElements,
|
||||
observeMutationsRoot: observeMutationsRoot
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1714,6 +1865,33 @@ var text = function text(content) {
|
||||
});
|
||||
};
|
||||
|
||||
var counter = function counter(content) {
|
||||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _params$title3 = params.title,
|
||||
title = _params$title3 === undefined ? null : _params$title3,
|
||||
_params$classes3 = params.classes,
|
||||
classes = _params$classes3 === undefined ? [] : _params$classes3,
|
||||
_params$attributes3 = params.attributes,
|
||||
attributes = _params$attributes3 === undefined ? {} : _params$attributes3,
|
||||
_params$styles3 = params.styles,
|
||||
styles = _params$styles3 === undefined ? {} : _params$styles3;
|
||||
|
||||
|
||||
return apiObject({ type: 'counter', content: content }, function () {
|
||||
ensureCss();
|
||||
|
||||
return makeLayersCounterAbstract({
|
||||
content: content.toString(),
|
||||
title: title,
|
||||
extra: {
|
||||
attributes: attributes,
|
||||
styles: styles,
|
||||
classes: [config.familyPrefix + '-layers-counter'].concat(toConsumableArray(classes))
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var layer = function layer(assembler) {
|
||||
return apiObject({ type: 'layer' }, function () {
|
||||
ensureCss();
|
||||
@@ -1736,17 +1914,25 @@ var layer = function layer(assembler) {
|
||||
|
||||
var api = {
|
||||
noAuto: noAuto,
|
||||
config: config,
|
||||
dom: dom,
|
||||
library: library,
|
||||
parse: parse,
|
||||
findIconDefinition: findIconDefinition,
|
||||
icon: icon,
|
||||
text: text,
|
||||
layer: layer
|
||||
counter: counter,
|
||||
layer: layer,
|
||||
toHtml: toHtml
|
||||
};
|
||||
|
||||
var autoReplace = function autoReplace() {
|
||||
if (IS_DOM && config.autoReplaceSvg) api.dom.i2svg({ node: DOCUMENT });
|
||||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var _params$autoReplaceSv = params.autoReplaceSvgRoot,
|
||||
autoReplaceSvgRoot = _params$autoReplaceSv === undefined ? DOCUMENT : _params$autoReplaceSv;
|
||||
|
||||
|
||||
if (Object.keys(namespace.styles).length > 0 && IS_DOM && config.autoReplaceSvg) api.dom.i2svg({ node: autoReplaceSvgRoot });
|
||||
};
|
||||
|
||||
function bootstrap() {
|
||||
@@ -1756,17 +1942,13 @@ function bootstrap() {
|
||||
}
|
||||
|
||||
domready(function () {
|
||||
if (Object.keys(namespace.styles).length > 0) {
|
||||
autoReplace();
|
||||
}
|
||||
autoReplace();
|
||||
|
||||
if (config.observeMutations && typeof MutationObserver === 'function') {
|
||||
observe({
|
||||
treeCallback: onTree,
|
||||
nodeCallback: onNode,
|
||||
pseudoElementsCallback: searchPseudoElements
|
||||
});
|
||||
}
|
||||
observe({
|
||||
treeCallback: onTree,
|
||||
nodeCallback: onNode,
|
||||
pseudoElementsCallback: searchPseudoElements
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1790,16 +1972,6 @@ function bootstrap() {
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(api, 'config', {
|
||||
get: function get() {
|
||||
return config;
|
||||
},
|
||||
|
||||
set: function set(newConfig) {
|
||||
update(newConfig);
|
||||
}
|
||||
});
|
||||
|
||||
bunker(bootstrap);
|
||||
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user