Release 5.0.0-rc4
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Font Awesome 5.0.0-rc3
|
||||
* Font Awesome 5.0.0-rc4
|
||||
*/
|
||||
|
||||
(function () {
|
||||
@@ -51,8 +51,9 @@ var NAMESPACE_IDENTIFIER = '___FONT_AWESOME___';
|
||||
var UNITS_IN_GRID = 16;
|
||||
var DEFAULT_FAMILY_PREFIX = 'fa';
|
||||
var DEFAULT_REPLACEMENT_CLASS = 'svg-inline--fa';
|
||||
var DATA_FA_REPLACEMENT = 'data-fa-replacement';
|
||||
var DATA_FA_PROCESSED = 'data-fa-processed';
|
||||
var DATA_FA_PSEUDO_ELEMENT = 'data-fa-pseudo-element';
|
||||
var HTML_CLASS_I2SVG_BASE_CLASS = 'fontawesome-i2svg';
|
||||
|
||||
var PRODUCTION = function () {
|
||||
try {
|
||||
@@ -490,7 +491,7 @@ function makeInlineSvgAbstract(params) {
|
||||
|
||||
var content = {
|
||||
children: [],
|
||||
attributes: _extends({}, extra.attributes, (_babelHelpers$extends = {}, defineProperty(_babelHelpers$extends, DATA_FA_REPLACEMENT, 'true'), defineProperty(_babelHelpers$extends, 'data-prefix', prefix), defineProperty(_babelHelpers$extends, 'data-icon', iconName), defineProperty(_babelHelpers$extends, 'class', attrClass), defineProperty(_babelHelpers$extends, 'role', 'img'), defineProperty(_babelHelpers$extends, 'xmlns', 'http://www.w3.org/2000/svg'), defineProperty(_babelHelpers$extends, 'viewBox', '0 0 ' + width + ' ' + height), _babelHelpers$extends))
|
||||
attributes: _extends({}, extra.attributes, (_babelHelpers$extends = {}, defineProperty(_babelHelpers$extends, DATA_FA_PROCESSED, ''), defineProperty(_babelHelpers$extends, 'data-prefix', prefix), defineProperty(_babelHelpers$extends, 'data-icon', iconName), defineProperty(_babelHelpers$extends, 'class', attrClass), defineProperty(_babelHelpers$extends, 'role', 'img'), defineProperty(_babelHelpers$extends, 'xmlns', 'http://www.w3.org/2000/svg'), defineProperty(_babelHelpers$extends, 'viewBox', '0 0 ' + width + ' ' + height), _babelHelpers$extends))
|
||||
};
|
||||
|
||||
if (title) content.children.push({ tag: 'title', attributes: { id: content.attributes['aria-labelledby'] || 'title-' + nextUniqueId() }, children: [title] });
|
||||
@@ -530,7 +531,7 @@ function makeLayersTextAbstract(params) {
|
||||
extra = params.extra;
|
||||
|
||||
|
||||
var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, (_babelHelpers$extends2 = {}, defineProperty(_babelHelpers$extends2, DATA_FA_REPLACEMENT, 'true'), defineProperty(_babelHelpers$extends2, 'class', extra.classes.join(' ')), _babelHelpers$extends2));
|
||||
var attributes = _extends({}, extra.attributes, title ? { 'title': title } : {}, (_babelHelpers$extends2 = {}, defineProperty(_babelHelpers$extends2, DATA_FA_PROCESSED, ''), defineProperty(_babelHelpers$extends2, 'class', extra.classes.join(' ')), _babelHelpers$extends2));
|
||||
|
||||
var styles = _extends({}, extra.styles);
|
||||
|
||||
@@ -569,9 +570,9 @@ if (!w[NAMESPACE_IDENTIFIER].shims) w[NAMESPACE_IDENTIFIER].shims = [];
|
||||
|
||||
var namespace = w[NAMESPACE_IDENTIFIER];
|
||||
|
||||
var noop$1 = function noop() {};
|
||||
var p = config.measurePerformance && PERFORMANCE && PERFORMANCE.mark && PERFORMANCE.measure ? PERFORMANCE : { mark: noop$1, measure: noop$1 };
|
||||
var preamble = 'FA "5.0.0-rc3"';
|
||||
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.0-rc4"';
|
||||
|
||||
var begin = function begin(name) {
|
||||
p.mark(preamble + ' ' + name + ' begins');
|
||||
@@ -602,6 +603,8 @@ function toHtml(abstractNodes) {
|
||||
}
|
||||
}
|
||||
|
||||
var noop$1 = function noop() {};
|
||||
|
||||
function isReplaced(node) {
|
||||
var nodeClass = node.getAttribute ? node.getAttribute('class') : null;
|
||||
|
||||
@@ -634,28 +637,59 @@ var mutators = {
|
||||
nest: function nest(mutation) {
|
||||
var node = mutation[0];
|
||||
var abstract = mutation[1];
|
||||
|
||||
// If we already have a replaced node we do not want to continue nesting within it.
|
||||
// Short-circuit to the standard replacement
|
||||
if (~toArray(node.classList).indexOf(config.replacementClass)) {
|
||||
return mutators.replace(mutation);
|
||||
}
|
||||
|
||||
var forSvg = new RegExp(config.familyPrefix + '-.*');
|
||||
|
||||
delete abstract[0].attributes.style;
|
||||
|
||||
var splitClasses = abstract[0].attributes.class.split(' ').reduce(function (acc, cls) {
|
||||
if (cls === config.replacementClass || cls.match(forSvg)) {
|
||||
acc.toSvg.push(cls);
|
||||
} else {
|
||||
acc.toNode.push(cls);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, { toNode: [], toSvg: [] });
|
||||
|
||||
abstract[0].attributes.class = splitClasses.toSvg.join(' ');
|
||||
|
||||
var newInnerHTML = abstract.map(function (a) {
|
||||
return toHtml(a);
|
||||
}).join('\n');
|
||||
node.setAttribute('class', splitClasses.toNode.join(' '));
|
||||
node.setAttribute(DATA_FA_PROCESSED, '');
|
||||
node.innerHTML = newInnerHTML;
|
||||
}
|
||||
};
|
||||
|
||||
function perform(mutations, callback) {
|
||||
if (!WINDOW.requestAnimationFrame) return;
|
||||
var callbackFunction = typeof callback === 'function' ? callback : noop$1;
|
||||
|
||||
WINDOW.requestAnimationFrame(function () {
|
||||
var mutator = getMutator();
|
||||
var end = perf.begin('mutate');
|
||||
if (mutations.length === 0) {
|
||||
callbackFunction();
|
||||
} else {
|
||||
var frame = WINDOW.requestAnimationFrame || function (op) {
|
||||
return op();
|
||||
};
|
||||
|
||||
mutations.map(mutator);
|
||||
frame(function () {
|
||||
var mutator = getMutator();
|
||||
var mark = perf.begin('mutate');
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
mutations.map(mutator);
|
||||
|
||||
end();
|
||||
});
|
||||
mark();
|
||||
|
||||
callbackFunction();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var disabled = false;
|
||||
@@ -670,16 +704,25 @@ function observe(options) {
|
||||
if (!MUTATION_OBSERVER) return;
|
||||
|
||||
var treeCallback = options.treeCallback,
|
||||
nodeCallback = options.nodeCallback;
|
||||
nodeCallback = options.nodeCallback,
|
||||
pseudoElementsCallback = options.pseudoElementsCallback;
|
||||
|
||||
var mo = new MUTATION_OBSERVER(function (objects) {
|
||||
if (disabled) return;
|
||||
|
||||
toArray(objects).forEach(function (mutationRecord) {
|
||||
if (mutationRecord.type === 'childList' && mutationRecord.addedNodes.length > 0 && !isReplaced(mutationRecord.addedNodes[0])) {
|
||||
if (config.searchPseudoElements) {
|
||||
pseudoElementsCallback(mutationRecord.target);
|
||||
}
|
||||
|
||||
treeCallback(mutationRecord.target);
|
||||
}
|
||||
|
||||
if (mutationRecord.type === 'attributes' && mutationRecord.attributeName === 'class' && mutationRecord.target.parentNode && config.searchPseudoElements) {
|
||||
pseudoElementsCallback(mutationRecord.target.parentNode);
|
||||
}
|
||||
|
||||
if (mutationRecord.type === 'attributes' && isReplaced(mutationRecord.target) && ~ATTRIBUTES_WATCHED_FOR_MUTATION.indexOf(mutationRecord.attributeName)) {
|
||||
nodeCallback(mutationRecord.target);
|
||||
}
|
||||
@@ -1194,14 +1237,19 @@ function searchPseudoElements(root) {
|
||||
var styles = WINDOW.getComputedStyle(node, pos);
|
||||
var fontFamily = styles.getPropertyValue('font-family').match(FONT_FAMILY_PATTERN);
|
||||
var children = toArray(node.children);
|
||||
var child = pos === ':before' ? children[0] : children.slice(-1)[0];
|
||||
var hasReplacement = child ? !!child.getAttribute(DATA_FA_PSEUDO_ELEMENT) : false;
|
||||
var pseudoElement = children.filter(function (c) {
|
||||
return c.getAttribute(DATA_FA_PSEUDO_ELEMENT) === pos;
|
||||
})[0];
|
||||
|
||||
if (fontFamily && !hasReplacement) {
|
||||
if (!fontFamily && pseudoElement) {
|
||||
pseudoElement.remove();
|
||||
}
|
||||
|
||||
if (fontFamily && !pseudoElement) {
|
||||
var content = styles.getPropertyValue('content');
|
||||
var i = DOCUMENT.createElement('i');
|
||||
i.setAttribute('class', '' + STYLE_TO_PREFIX[fontFamily[1]]);
|
||||
i.setAttribute(DATA_FA_PSEUDO_ELEMENT, true);
|
||||
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);
|
||||
@@ -1221,33 +1269,32 @@ function onTree(root) {
|
||||
|
||||
var htmlClassList = DOCUMENT.documentElement.classList;
|
||||
var hclAdd = function hclAdd(suffix) {
|
||||
return htmlClassList.add('font-awesome-i2svg-' + suffix);
|
||||
return htmlClassList.add(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
|
||||
};
|
||||
var hclRemove = function hclRemove(suffix) {
|
||||
return htmlClassList.remove('font-awesome-i2svg-' + suffix);
|
||||
return htmlClassList.remove(HTML_CLASS_I2SVG_BASE_CLASS + '-' + suffix);
|
||||
};
|
||||
var prefixes = Object.keys(packs);
|
||||
var prefixesDomQuery = ['.' + LAYERS_TEXT_CLASSNAME].concat(prefixes.map(function (p) {
|
||||
return '.' + p;
|
||||
var prefixesDomQuery = ['.' + LAYERS_TEXT_CLASSNAME + ':not([' + DATA_FA_PROCESSED + '])'].concat(prefixes.map(function (p) {
|
||||
return '.' + p + ':not([' + DATA_FA_PROCESSED + '])';
|
||||
})).join(', ');
|
||||
|
||||
hclAdd('active');
|
||||
hclAdd('pending');
|
||||
hclRemove('complete');
|
||||
|
||||
if (prefixesDomQuery.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.searchPseudoElements) {
|
||||
searchPseudoElements(root);
|
||||
var candidates = toArray(root.querySelectorAll(prefixesDomQuery));
|
||||
|
||||
if (candidates.length > 0) {
|
||||
hclAdd('pending');
|
||||
hclRemove('complete');
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var end = perf.begin('onTree');
|
||||
|
||||
var mutations = toArray(root.querySelectorAll(prefixesDomQuery)).reduce(function (acc, node) {
|
||||
if (node.getAttribute(DATA_FA_REPLACEMENT)) return acc;
|
||||
var mark = perf.begin('onTree');
|
||||
|
||||
var mutations = candidates.reduce(function (acc, node) {
|
||||
try {
|
||||
var mutation = generateMutation(node);
|
||||
|
||||
@@ -1265,9 +1312,10 @@ function onTree(root) {
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
end();
|
||||
mark();
|
||||
|
||||
perform(mutations, function () {
|
||||
hclAdd('active');
|
||||
hclAdd('complete');
|
||||
hclRemove('pending');
|
||||
|
||||
@@ -1451,6 +1499,10 @@ var api = {
|
||||
callback = _params$callback === undefined ? function () {} : _params$callback;
|
||||
|
||||
|
||||
if (config.searchPseudoElements) {
|
||||
searchPseudoElements(node);
|
||||
}
|
||||
|
||||
onTree(node, callback);
|
||||
},
|
||||
|
||||
@@ -1610,7 +1662,11 @@ function bootstrap() {
|
||||
}
|
||||
|
||||
if (config.observeMutations && typeof MutationObserver === 'function') {
|
||||
observe({ treeCallback: onTree, nodeCallback: onNode });
|
||||
observe({
|
||||
treeCallback: onTree,
|
||||
nodeCallback: onNode,
|
||||
pseudoElementsCallback: searchPseudoElements
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user