зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1425876 - Update Debugger frontend (12-18). r=jdescottes
MozReview-Commit-ID: H6oKTciiKRO --HG-- extra : rebase_source : 1e45afed51b1296aa4ba89b33cc20730ff8ade82
This commit is contained in:
Родитель
a4ab509570
Коммит
13de9fd4ca
|
@ -1,7 +1,7 @@
|
|||
This is the debugger.html project output.
|
||||
See https://github.com/devtools-html/debugger.html
|
||||
|
||||
Taken from upstream commit: 95faec6ebf536f313288cd67868d560b52b1dc5b
|
||||
Taken from upstream commit: 53faca589b021f01c7af5980c8c0e98b58c02e4c
|
||||
|
||||
Packages:
|
||||
- babel-plugin-transform-es2015-modules-commonjs @6.26.0
|
||||
|
|
|
@ -1631,53 +1631,83 @@ html[dir="rtl"] .managed-tree .tree .node > div {
|
|||
.function-signature .comma {
|
||||
color: var(--object-color);
|
||||
}
|
||||
.command-bar-button {
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
padding: 0px 5px;
|
||||
margin-inline-end: 0.3em;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.command-bar-button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.command-bar-button:disabled {
|
||||
opacity: 0.8;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.command-bar-button:not(.disabled):hover {
|
||||
background: var(--theme-toolbar-background-hover);
|
||||
}
|
||||
|
||||
:root.theme-dark .command-bar-button {
|
||||
color: var(--theme-body-color);
|
||||
}
|
||||
|
||||
.command-bar-button > * {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
.toggle-button-start,
|
||||
.toggle-button-end {
|
||||
.toggle-button {
|
||||
transform: translate(0, 0px);
|
||||
transition: transform 0.25s ease-in-out;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.toggle-button-start.vertical,
|
||||
.toggle-button-end.vertical {
|
||||
.toggle-button.vertical {
|
||||
padding: 2.5px 2.5px;
|
||||
}
|
||||
|
||||
.toggle-button-start svg,
|
||||
.toggle-button-end svg {
|
||||
width: 16px;
|
||||
.toggle-button svg {
|
||||
fill: var(--theme-comment);
|
||||
}
|
||||
|
||||
.theme-dark .toggle-button-start svg,
|
||||
.theme-dark .toggle-button-end svg {
|
||||
:root.theme-dark .toggle-button svg {
|
||||
fill: var(--theme-comment-alt);
|
||||
}
|
||||
|
||||
.toggle-button-end {
|
||||
.toggle-button.end {
|
||||
margin-inline-end: 0px;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.toggle-button-start {
|
||||
.toggle-button.start {
|
||||
margin-inline-start: 0px;
|
||||
}
|
||||
|
||||
html:not([dir="rtl"]) .toggle-button-end svg,
|
||||
html[dir="rtl"] .toggle-button-start svg {
|
||||
html:not([dir="rtl"]) .toggle-button.end svg,
|
||||
html[dir="rtl"] .toggle-button.start svg {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
html .toggle-button-end.vertical svg {
|
||||
html .toggle-button.end.vertical svg {
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.toggle-button-start.collapsed,
|
||||
.toggle-button-end.collapsed {
|
||||
.toggle-button.start.collapsed,
|
||||
.toggle-button.end.collapsed {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
|
@ -3242,40 +3272,6 @@ html[dir="rtl"] .command-bar {
|
|||
background-color: var(--theme-tab-toolbar-background);
|
||||
}
|
||||
|
||||
.command-bar > button {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
border: none;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
padding: 8px 5px;
|
||||
position: relative;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.command-bar > button:not(.disabled):hover {
|
||||
background: var(--theme-toolbar-background-hover);
|
||||
}
|
||||
|
||||
:root.theme-dark .command-bar > button {
|
||||
color: var(--theme-body-color);
|
||||
}
|
||||
|
||||
.command-bar > button {
|
||||
margin-inline-end: 0.3em;
|
||||
}
|
||||
|
||||
.command-bar > button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
html .command-bar > button:disabled {
|
||||
opacity: 0.8;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
img.pause,
|
||||
img.stepOver,
|
||||
img.stepIn,
|
||||
|
@ -3284,45 +3280,39 @@ img.resume {
|
|||
background-color: var(--theme-body-color);
|
||||
}
|
||||
|
||||
.command-bar > button > img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.command-bar > button > img.pause {
|
||||
.command-bar img.pause {
|
||||
mask: url("chrome://devtools/skin/images/debugger/pause.svg") no-repeat;
|
||||
}
|
||||
|
||||
.command-bar > button > img.stepOver {
|
||||
.command-bar img.stepOver {
|
||||
mask: url("chrome://devtools/skin/images/debugger/stepOver.svg") no-repeat;
|
||||
}
|
||||
|
||||
.command-bar > button > img.stepIn {
|
||||
.command-bar img.stepIn {
|
||||
mask: url("chrome://devtools/skin/images/debugger/stepIn.svg") no-repeat;
|
||||
}
|
||||
|
||||
.command-bar > button > img.stepOut {
|
||||
.command-bar img.stepOut {
|
||||
mask: url("chrome://devtools/skin/images/debugger/stepOut.svg") no-repeat;
|
||||
}
|
||||
|
||||
.command-bar > button > img.resume {
|
||||
.command-bar img.resume {
|
||||
mask: url("chrome://devtools/skin/images/debugger/resume.svg") no-repeat;
|
||||
}
|
||||
|
||||
.command-bar > button.pause-exceptions.uncaught.enabled > img.pause-exceptions {
|
||||
.command-bar > .pause-exceptions.uncaught.enabled > img.pause-exceptions {
|
||||
background-color: var(--theme-highlight-purple);
|
||||
}
|
||||
|
||||
.command-bar > button.pause-exceptions.all.enabled > img.pause-exceptions {
|
||||
.command-bar > .pause-exceptions.all.enabled > img.pause-exceptions {
|
||||
background-color: var(--theme-highlight-blue);
|
||||
}
|
||||
|
||||
.command-bar > button.pause-exceptions.enabled > img.pause-exceptions {
|
||||
.command-bar > .pause-exceptions.enabled > img.pause-exceptions {
|
||||
background-color: var(--theme-body-color);
|
||||
}
|
||||
|
||||
.command-bar > button > img.pause-exceptions {
|
||||
.command-bar img.pause-exceptions {
|
||||
mask: url("chrome://devtools/skin/images/debugger/pause-exceptions.svg") no-repeat;
|
||||
margin-inline-start: 0.2em;
|
||||
}
|
||||
|
@ -3338,10 +3328,6 @@ img.resume {
|
|||
flex: 0 0 27px;
|
||||
}
|
||||
|
||||
.command-bar > button {
|
||||
padding: 6px 5px;
|
||||
}
|
||||
|
||||
.command-bar.bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
@ -3683,7 +3669,6 @@ html .welcomebox .toggle-button-end.collapsed {
|
|||
width: 100%;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.source-header * {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -31653,40 +31653,19 @@ module.exports = isEmpty;
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parseScriptTags = exports.parseScripts = exports.parseScript = exports.getCandidateScriptLocations = exports.generateWhitespace = exports.extractScriptTags = undefined;
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
var _babelTypes = __webpack_require__(493);
|
||||
|
||||
var babylon = __webpack_require__(435);
|
||||
var types = __webpack_require__(493);
|
||||
var types = _interopRequireWildcard(_babelTypes);
|
||||
|
||||
var startScript = /<script[^>]*>/im;
|
||||
var endScript = /<\/script\s*>/im;
|
||||
// https://stackoverflow.com/questions/5034781/js-regex-to-split-by-line#comment5633979_5035005
|
||||
var newLines = /\r\n|[\n\v\f\r\x85\u2028\u2029]/;
|
||||
var _babylon = __webpack_require__(435);
|
||||
|
||||
function getCandidateScriptLocations(source, index) {
|
||||
var i = index || 0;
|
||||
var str = source.substring(i);
|
||||
var babylon = _interopRequireWildcard(_babylon);
|
||||
|
||||
var startMatch = startScript.exec(str);
|
||||
if (startMatch) {
|
||||
var startsAt = startMatch.index + startMatch[0].length;
|
||||
var afterStart = str.substring(startsAt);
|
||||
var endMatch = endScript.exec(afterStart);
|
||||
if (endMatch) {
|
||||
var locLength = endMatch.index;
|
||||
var locIndex = i + startsAt;
|
||||
var _customParse = __webpack_require__(1794);
|
||||
|
||||
return [adjustForLineAndColumn(source, {
|
||||
index: locIndex,
|
||||
length: locLength,
|
||||
source: source.substring(locIndex, locIndex + locLength)
|
||||
})].concat(_toConsumableArray(getCandidateScriptLocations(source, locIndex + locLength + endMatch[0].length)));
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function parseScript(_ref) {
|
||||
var source = _ref.source,
|
||||
|
@ -31710,69 +31689,11 @@ function parseScript(_ref) {
|
|||
function parseScripts(locations) {
|
||||
var parser = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : parseScript;
|
||||
|
||||
return locations.map(parser);
|
||||
}
|
||||
|
||||
function generateWhitespace(length) {
|
||||
return Array.from(new Array(length + 1)).join(" ");
|
||||
}
|
||||
|
||||
function calcLineAndColumn(source, index) {
|
||||
var lines = source.substring(0, index).split(newLines);
|
||||
var line = lines.length;
|
||||
var column = lines.pop().length + 1;
|
||||
|
||||
return {
|
||||
column: column,
|
||||
line: line
|
||||
};
|
||||
}
|
||||
|
||||
function adjustForLineAndColumn(fullSource, location) {
|
||||
var _calcLineAndColumn = calcLineAndColumn(fullSource, location.index),
|
||||
column = _calcLineAndColumn.column,
|
||||
line = _calcLineAndColumn.line;
|
||||
|
||||
return Object.assign({}, location, {
|
||||
line: line,
|
||||
column: column,
|
||||
// prepend whitespace for scripts that do not start on the first column
|
||||
source: generateWhitespace(column) + location.source
|
||||
});
|
||||
}
|
||||
|
||||
function parseScriptTags(source, parser) {
|
||||
var scripts = parseScripts(getCandidateScriptLocations(source), parser).filter(types.isFile).reduce(function (main, script) {
|
||||
return {
|
||||
statements: main.statements.concat(script.program.body),
|
||||
comments: main.comments.concat(script.comments),
|
||||
tokens: main.tokens.concat(script.tokens)
|
||||
};
|
||||
}, {
|
||||
statements: [],
|
||||
comments: [],
|
||||
tokens: []
|
||||
});
|
||||
|
||||
var program = types.program(scripts.statements);
|
||||
var file = types.file(program, scripts.comments, scripts.tokens);
|
||||
|
||||
var end = calcLineAndColumn(source, source.length);
|
||||
file.start = program.start = 0;
|
||||
file.end = program.end = source.length;
|
||||
file.loc = program.loc = {
|
||||
start: {
|
||||
line: 1,
|
||||
column: 0
|
||||
},
|
||||
end: end
|
||||
};
|
||||
|
||||
return file;
|
||||
return (0, _customParse.parseScripts)(locations, parser);
|
||||
}
|
||||
|
||||
function extractScriptTags(source) {
|
||||
return parseScripts(getCandidateScriptLocations(source), function (loc) {
|
||||
return parseScripts((0, _customParse.getCandidateScriptLocations)(source), function (loc) {
|
||||
var ast = parseScript(loc);
|
||||
|
||||
if (ast) {
|
||||
|
@ -31783,10 +31704,16 @@ function extractScriptTags(source) {
|
|||
}).filter(types.isFile);
|
||||
}
|
||||
|
||||
function parseScriptTags(source) {
|
||||
var parser = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : parseScript;
|
||||
|
||||
return (0, _customParse.parseScriptTags)(source, parser);
|
||||
}
|
||||
|
||||
exports.default = parseScriptTags;
|
||||
exports.extractScriptTags = extractScriptTags;
|
||||
exports.generateWhitespace = generateWhitespace;
|
||||
exports.getCandidateScriptLocations = getCandidateScriptLocations;
|
||||
exports.generateWhitespace = _customParse.generateWhitespace;
|
||||
exports.getCandidateScriptLocations = _customParse.getCandidateScriptLocations;
|
||||
exports.parseScript = parseScript;
|
||||
exports.parseScripts = parseScripts;
|
||||
exports.parseScriptTags = parseScriptTags;
|
||||
|
@ -35988,6 +35915,7 @@ function extractSymbols(source) {
|
|||
const identifiers = [];
|
||||
const classes = [];
|
||||
const imports = [];
|
||||
let hasJsx = false;
|
||||
|
||||
const ast = (0, _ast.traverseAst)(source, {
|
||||
enter(path) {
|
||||
|
@ -36005,6 +35933,10 @@ function extractSymbols(source) {
|
|||
});
|
||||
}
|
||||
|
||||
if (t.isJSXElement(path)) {
|
||||
hasJsx = true;
|
||||
}
|
||||
|
||||
if (t.isClassDeclaration(path)) {
|
||||
classes.push({
|
||||
name: path.node.id.name,
|
||||
|
@ -36102,7 +36034,8 @@ function extractSymbols(source) {
|
|||
comments,
|
||||
identifiers,
|
||||
classes,
|
||||
imports
|
||||
imports,
|
||||
hasJsx
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41876,6 +41809,344 @@ function baseToPairs(object, props) {
|
|||
module.exports = baseToPairs;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 1758 */,
|
||||
/* 1759 */,
|
||||
/* 1760 */,
|
||||
/* 1761 */,
|
||||
/* 1762 */,
|
||||
/* 1763 */,
|
||||
/* 1764 */,
|
||||
/* 1765 */,
|
||||
/* 1766 */,
|
||||
/* 1767 */,
|
||||
/* 1768 */,
|
||||
/* 1769 */,
|
||||
/* 1770 */,
|
||||
/* 1771 */,
|
||||
/* 1772 */,
|
||||
/* 1773 */,
|
||||
/* 1774 */,
|
||||
/* 1775 */,
|
||||
/* 1776 */,
|
||||
/* 1777 */,
|
||||
/* 1778 */,
|
||||
/* 1779 */,
|
||||
/* 1780 */,
|
||||
/* 1781 */,
|
||||
/* 1782 */,
|
||||
/* 1783 */,
|
||||
/* 1784 */,
|
||||
/* 1785 */,
|
||||
/* 1786 */,
|
||||
/* 1787 */,
|
||||
/* 1788 */,
|
||||
/* 1789 */,
|
||||
/* 1790 */,
|
||||
/* 1791 */,
|
||||
/* 1792 */,
|
||||
/* 1793 */,
|
||||
/* 1794 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parseScriptTags = exports.parseScripts = exports.getCandidateScriptLocations = exports.generateWhitespace = undefined;
|
||||
|
||||
var _babelTypes = __webpack_require__(493);
|
||||
|
||||
var types = _interopRequireWildcard(_babelTypes);
|
||||
|
||||
var _parseScriptFragment = __webpack_require__(1795);
|
||||
|
||||
var _parseScriptFragment2 = _interopRequireDefault(_parseScriptFragment);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
var startScript = /<script[^>]*>/im;
|
||||
var endScript = /<\/script\s*>/im;
|
||||
// https://stackoverflow.com/questions/5034781/js-regex-to-split-by-line#comment5633979_5035005
|
||||
var newLines = /\r\n|[\n\v\f\r\x85\u2028\u2029]/;
|
||||
|
||||
function getType(tag) {
|
||||
var fragment = (0, _parseScriptFragment2.default)(tag);
|
||||
|
||||
if (fragment) {
|
||||
var type = fragment.attributes.type;
|
||||
|
||||
return type ? type.toLowerCase() : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getCandidateScriptLocations(source, index) {
|
||||
var i = index || 0;
|
||||
var str = source.substring(i);
|
||||
|
||||
var startMatch = startScript.exec(str);
|
||||
if (startMatch) {
|
||||
var startsAt = startMatch.index + startMatch[0].length;
|
||||
var afterStart = str.substring(startsAt);
|
||||
var endMatch = endScript.exec(afterStart);
|
||||
if (endMatch) {
|
||||
var locLength = endMatch.index;
|
||||
var locIndex = i + startsAt;
|
||||
var endIndex = locIndex + locLength + endMatch[0].length;
|
||||
|
||||
// extract the complete tag (incl start and end tags and content). if the
|
||||
// type is invalid (= not JS), skip this tag and continue
|
||||
var tag = source.substring(i + startMatch.index, endIndex);
|
||||
var type = getType(tag);
|
||||
if (type && type !== "javascript" && type !== "text/javascript") {
|
||||
return getCandidateScriptLocations(source, endIndex);
|
||||
}
|
||||
|
||||
return [adjustForLineAndColumn(source, {
|
||||
index: locIndex,
|
||||
length: locLength,
|
||||
source: source.substring(locIndex, locIndex + locLength)
|
||||
})].concat(_toConsumableArray(getCandidateScriptLocations(source, endIndex)));
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function parseScripts(locations, parser) {
|
||||
return locations.map(parser);
|
||||
}
|
||||
|
||||
function generateWhitespace(length) {
|
||||
return Array.from(new Array(length + 1)).join(" ");
|
||||
}
|
||||
|
||||
function calcLineAndColumn(source, index) {
|
||||
var lines = source.substring(0, index).split(newLines);
|
||||
var line = lines.length;
|
||||
var column = lines.pop().length + 1;
|
||||
|
||||
return {
|
||||
column: column,
|
||||
line: line
|
||||
};
|
||||
}
|
||||
|
||||
function adjustForLineAndColumn(fullSource, location) {
|
||||
var _calcLineAndColumn = calcLineAndColumn(fullSource, location.index),
|
||||
column = _calcLineAndColumn.column,
|
||||
line = _calcLineAndColumn.line;
|
||||
|
||||
return Object.assign({}, location, {
|
||||
line: line,
|
||||
column: column,
|
||||
// prepend whitespace for scripts that do not start on the first column
|
||||
source: generateWhitespace(column) + location.source
|
||||
});
|
||||
}
|
||||
|
||||
function parseScriptTags(source, parser) {
|
||||
var scripts = parseScripts(getCandidateScriptLocations(source), parser).filter(types.isFile).reduce(function (main, script) {
|
||||
return {
|
||||
statements: main.statements.concat(script.program.body),
|
||||
comments: main.comments.concat(script.comments),
|
||||
tokens: main.tokens.concat(script.tokens)
|
||||
};
|
||||
}, {
|
||||
statements: [],
|
||||
comments: [],
|
||||
tokens: []
|
||||
});
|
||||
|
||||
var program = types.program(scripts.statements);
|
||||
var file = types.file(program, scripts.comments, scripts.tokens);
|
||||
|
||||
var end = calcLineAndColumn(source, source.length);
|
||||
file.start = program.start = 0;
|
||||
file.end = program.end = source.length;
|
||||
file.loc = program.loc = {
|
||||
start: {
|
||||
line: 1,
|
||||
column: 0
|
||||
},
|
||||
end: end
|
||||
};
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
exports.default = parseScriptTags;
|
||||
exports.generateWhitespace = generateWhitespace;
|
||||
exports.getCandidateScriptLocations = getCandidateScriptLocations;
|
||||
exports.parseScripts = parseScripts;
|
||||
exports.parseScriptTags = parseScriptTags;
|
||||
|
||||
/***/ }),
|
||||
/* 1795 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var alphanum = /[a-z0-9\-]/i;
|
||||
|
||||
function parseToken(str, start) {
|
||||
var i = start;
|
||||
while (i < str.length && alphanum.test(str.charAt(i++))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i !== start) {
|
||||
return {
|
||||
token: str.substring(start, i - 1),
|
||||
index: i
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseAttributes(str, start) {
|
||||
var i = start;
|
||||
var attributes = {};
|
||||
var attribute = null;
|
||||
|
||||
while (i < str.length) {
|
||||
var c = str.charAt(i);
|
||||
|
||||
if (attribute === null && c == ">") {
|
||||
break;
|
||||
} else if (attribute === null && alphanum.test(c)) {
|
||||
attribute = {
|
||||
name: null,
|
||||
value: true,
|
||||
bool: true,
|
||||
terminator: null
|
||||
};
|
||||
|
||||
var attributeNameNode = parseToken(str, i);
|
||||
if (attributeNameNode) {
|
||||
attribute.name = attributeNameNode.token;
|
||||
i = attributeNameNode.index - 2;
|
||||
}
|
||||
} else if (attribute !== null) {
|
||||
if (c === "=") {
|
||||
// once we've started an attribute, look for = to indicate
|
||||
// it's a non-boolean attribute
|
||||
attribute.bool = false;
|
||||
if (attribute.value === true) {
|
||||
attribute.value = "";
|
||||
}
|
||||
} else if (!attribute.bool && attribute.terminator === null && (c === '"' || c === "'")) {
|
||||
// once we've determined it's non-boolean, look for a
|
||||
// value terminator (", ')
|
||||
attribute.terminator = c;
|
||||
} else if (attribute.terminator) {
|
||||
if (c === attribute.terminator) {
|
||||
// if we had a terminator and found another, we've
|
||||
// reach the end of the attribute
|
||||
attributes[attribute.name] = attribute.value;
|
||||
attribute = null;
|
||||
} else {
|
||||
// otherwise, append the character to the attribute value
|
||||
attribute.value += c;
|
||||
|
||||
// check for an escaped terminator and push it as well
|
||||
// to avoid terminating prematurely
|
||||
if (c === "\\") {
|
||||
var next = str.charAt(i + 1);
|
||||
if (next === attribute.terminator) {
|
||||
attribute.value += next;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!/\s/.test(c)) {
|
||||
// if we've hit a non-space character and aren't processing a value,
|
||||
// we're starting a new attribute so push the attribute and clear the
|
||||
// local variable
|
||||
attributes[attribute.name] = attribute.value;
|
||||
attribute = null;
|
||||
|
||||
// move the cursor back to re-find the start of the attribute
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i !== start) {
|
||||
return {
|
||||
attributes: attributes,
|
||||
index: i
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseFragment(str) {
|
||||
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
|
||||
var tag = null;
|
||||
var open = false;
|
||||
var attributes = {};
|
||||
|
||||
var i = start;
|
||||
while (i < str.length) {
|
||||
var c = str.charAt(i++);
|
||||
|
||||
if (!open && !tag && c === "<") {
|
||||
// Open Start Tag
|
||||
open = true;
|
||||
|
||||
var tagNode = parseToken(str, i);
|
||||
if (!tagNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
i = tagNode.index - 1;
|
||||
tag = tagNode.token;
|
||||
} else if (open && c === ">") {
|
||||
// Close Start Tag
|
||||
break;
|
||||
} else if (open) {
|
||||
// Attributes
|
||||
var attributeNode = parseAttributes(str, i - 1);
|
||||
|
||||
if (attributeNode) {
|
||||
i = attributeNode.index;
|
||||
attributes = attributeNode.attributes || attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tag) {
|
||||
return {
|
||||
tag: tag,
|
||||
attributes: attributes
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
exports.default = parseFragment;
|
||||
exports.parseFragment = parseFragment;
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.925 12.5l7.4-5-7.4-5v10zM6 12.5v-10c0-.785.8-1.264 1.415-.848l7.4 5c.58.392.58 1.304 0 1.696l-7.4 5C6.8 13.764 6 13.285 6 12.5z" fill-rule="evenodd"/>
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<path fill="black" id="svg_1" fill-rule="evenodd" d="m4.55195,12.97461l7.4,-5l-7.4,-5l0,10zm-0.925,0l0,-10c0,-0.785 0.8,-1.264 1.415,-0.848l7.4,5c0.58,0.392 0.58,1.304 0,1.696l-7.4,5c-0.615,0.416 -1.415,-0.063 -1.415,-0.848z"/>
|
||||
</svg>
|
||||
|
|
До Ширина: | Высота: | Размер: 468 B После Ширина: | Высота: | Размер: 552 B |
Загрузка…
Ссылка в новой задаче