chrome-devtools-frontend 1.0.946920 → 1.0.948445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/config/gni/all_devtools_files.gni +1 -13
- package/config/gni/devtools_grd_files.gni +6 -9
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/.eslintrc.js +6 -1
- package/front_end/Images/src/circled_backslash_icon.svg +3 -0
- package/front_end/core/host/InspectorFrontendHost.ts +0 -3
- package/front_end/core/host/UserMetrics.ts +1 -1
- package/front_end/core/i18n/locales/en-US.json +17 -14
- package/front_end/core/i18n/locales/en-XL.json +17 -14
- package/front_end/core/platform/platform.ts +0 -2
- package/front_end/core/platform/string-utilities.ts +14 -1
- package/front_end/core/platform/utilities.ts +0 -29
- package/front_end/core/root/Runtime.ts +4 -211
- package/front_end/core/sdk/AccessibilityModel.ts +0 -2
- package/front_end/core/sdk/CSSProperty.ts +0 -2
- package/front_end/core/sdk/CSSRule.ts +0 -2
- package/front_end/core/sdk/Cookie.ts +0 -25
- package/front_end/core/sdk/EmulationModel.ts +0 -2
- package/front_end/core/sdk/HeapProfilerModel.ts +0 -2
- package/front_end/core/sdk/NetworkManager.ts +0 -3
- package/front_end/core/sdk/Resource.ts +0 -3
- package/front_end/core/sdk/ResourceTreeModel.ts +0 -3
- package/front_end/core/sdk/ServiceWorkerManager.ts +0 -2
- package/front_end/core/sdk/sdk-legacy.ts +0 -3
- package/front_end/entrypoints/devtools_app/{devtools_app-meta-files.ts → devtools_app.ts} +9 -2
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +2 -1
- package/front_end/entrypoints/inspector/{inspector.js → inspector.ts} +0 -3
- package/front_end/entrypoints/js_app/{JsMain.ts → js_app.ts} +5 -1
- package/front_end/entrypoints/main/MainImpl.ts +0 -1
- package/front_end/entrypoints/ndb_app/{ndb_app.js → ndb_app.ts} +0 -2
- package/front_end/entrypoints/node_app/node_app.ts +1 -3
- package/front_end/entrypoints/shell/{shell.js → shell.ts} +0 -2
- package/front_end/entrypoints/worker_app/{worker_app.js → worker_app.ts} +3 -2
- package/front_end/generated/InspectorBackendCommands.js +5 -1
- package/front_end/generated/protocol.d.ts +12 -0
- package/front_end/legacy/legacy-defs.d.ts +0 -4
- package/front_end/legacy_test_runner/test_runner/TestRunner.js +35 -59
- package/front_end/models/bindings/CompilerScriptMapping.ts +0 -1
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +4 -11
- package/front_end/models/bindings/SASSSourceMapping.ts +0 -1
- package/front_end/models/emulation/DeviceModeModel.ts +0 -2
- package/front_end/models/issues_manager/CorsIssue.ts +17 -9
- package/front_end/models/issues_manager/descriptions/{corsInsecurePrivateNetworkPreflight.md → corsPreflightAllowPrivateNetworkError.md} +1 -1
- package/front_end/panels/accessibility/AccessibilitySidebarView.ts +3 -1
- package/front_end/panels/animation/AnimationTimeline.ts +0 -2
- package/front_end/panels/animation/AnimationUI.ts +0 -2
- package/front_end/panels/application/BackForwardCacheStrings.ts +2 -5
- package/front_end/panels/application/BackForwardCacheView.ts +150 -58
- package/front_end/panels/application/ResourcesPanel.ts +0 -42
- package/front_end/panels/application/application-legacy.ts +0 -3
- package/front_end/panels/application/application-meta.ts +0 -13
- package/front_end/panels/application/backForwardCacheView.css +44 -6
- package/front_end/panels/application/components/FrameDetailsView.ts +3 -3
- package/front_end/panels/application/components/OriginTrialTreeView.ts +3 -3
- package/front_end/panels/application/components/StackTrace.ts +1 -1
- package/front_end/panels/coverage/CoverageView.ts +1 -1
- package/front_end/panels/css_overview/CSSOverviewModel.ts +0 -2
- package/front_end/panels/css_overview/CSSOverviewPanel.ts +0 -7
- package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +0 -2
- package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -0
- package/front_end/panels/css_overview/cssOverviewCompletedView.css +1 -1
- package/front_end/panels/developer_resources/DeveloperResourcesView.ts +2 -1
- package/front_end/panels/elements/ElementsPanel.ts +9 -1
- package/front_end/panels/elements/ElementsTreeElement.ts +1 -1
- package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +1 -1
- package/front_end/panels/issues/CorsIssueDetailsView.ts +18 -2
- package/front_end/panels/lighthouse/lighthouse-meta.ts +0 -3
- package/front_end/panels/network/NetworkWaterfallColumn.ts +2 -0
- package/front_end/panels/profiler/CPUProfileFlameChart.ts +3 -1
- package/front_end/panels/profiler/ProfileDataGrid.ts +2 -1
- package/front_end/panels/search/SearchView.ts +24 -4
- package/front_end/panels/settings/components/SyncSection.ts +2 -2
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +46 -46
- package/front_end/panels/sources/CSSPlugin.ts +3 -0
- package/front_end/panels/sources/CoveragePlugin.ts +2 -0
- package/front_end/panels/sources/DebuggerPlugin.ts +28 -4
- package/front_end/panels/sources/JavaScriptCompilerPlugin.ts +3 -0
- package/front_end/panels/sources/ProfilePlugin.ts +3 -0
- package/front_end/panels/sources/UISourceCodeFrame.ts +11 -2
- package/front_end/panels/timeline/TimelineTreeView.ts +2 -1
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/cpp.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/java.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/json.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/markdown.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/php.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/python.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/wast.js +1 -2
- package/front_end/third_party/codemirror.next/chunk/xml.js +1 -2
- package/front_end/third_party/codemirror.next/codemirror.next.js +1 -2
- package/front_end/third_party/codemirror.next/package.json +1 -0
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +168 -164
- package/front_end/third_party/lighthouse/locales/ar-XB.json +0 -3
- package/front_end/third_party/lighthouse/locales/ar.json +0 -3
- package/front_end/third_party/lighthouse/locales/bg.json +17 -20
- package/front_end/third_party/lighthouse/locales/ca.json +0 -3
- package/front_end/third_party/lighthouse/locales/cs.json +0 -3
- package/front_end/third_party/lighthouse/locales/da.json +16 -19
- package/front_end/third_party/lighthouse/locales/de.json +0 -3
- package/front_end/third_party/lighthouse/locales/el.json +0 -3
- package/front_end/third_party/lighthouse/locales/en-GB.json +19 -22
- package/front_end/third_party/lighthouse/locales/en-US.json +33 -3
- package/front_end/third_party/lighthouse/locales/en-XA.json +0 -3
- package/front_end/third_party/lighthouse/locales/en-XL.json +33 -3
- package/front_end/third_party/lighthouse/locales/es-419.json +17 -20
- package/front_end/third_party/lighthouse/locales/es.json +0 -3
- package/front_end/third_party/lighthouse/locales/fi.json +16 -19
- package/front_end/third_party/lighthouse/locales/fil.json +33 -36
- package/front_end/third_party/lighthouse/locales/fr.json +16 -19
- package/front_end/third_party/lighthouse/locales/he.json +16 -19
- package/front_end/third_party/lighthouse/locales/hi.json +0 -3
- package/front_end/third_party/lighthouse/locales/hr.json +16 -19
- package/front_end/third_party/lighthouse/locales/hu.json +16 -19
- package/front_end/third_party/lighthouse/locales/id.json +16 -19
- package/front_end/third_party/lighthouse/locales/it.json +37 -40
- package/front_end/third_party/lighthouse/locales/ja.json +16 -19
- package/front_end/third_party/lighthouse/locales/ko.json +16 -19
- package/front_end/third_party/lighthouse/locales/lt.json +17 -20
- package/front_end/third_party/lighthouse/locales/lv.json +0 -3
- package/front_end/third_party/lighthouse/locales/nl.json +16 -19
- package/front_end/third_party/lighthouse/locales/no.json +17 -20
- package/front_end/third_party/lighthouse/locales/pl.json +16 -19
- package/front_end/third_party/lighthouse/locales/pt-PT.json +37 -40
- package/front_end/third_party/lighthouse/locales/pt.json +16 -19
- package/front_end/third_party/lighthouse/locales/ro.json +0 -3
- package/front_end/third_party/lighthouse/locales/ru.json +16 -19
- package/front_end/third_party/lighthouse/locales/sk.json +0 -3
- package/front_end/third_party/lighthouse/locales/sl.json +0 -3
- package/front_end/third_party/lighthouse/locales/sr-Latn.json +16 -19
- package/front_end/third_party/lighthouse/locales/sr.json +16 -19
- package/front_end/third_party/lighthouse/locales/sv.json +17 -20
- package/front_end/third_party/lighthouse/locales/ta.json +0 -3
- package/front_end/third_party/lighthouse/locales/te.json +0 -3
- package/front_end/third_party/lighthouse/locales/th.json +0 -3
- package/front_end/third_party/lighthouse/locales/tr.json +0 -3
- package/front_end/third_party/lighthouse/locales/uk.json +17 -20
- package/front_end/third_party/lighthouse/locales/vi.json +0 -3
- package/front_end/third_party/lighthouse/locales/zh-HK.json +0 -3
- package/front_end/third_party/lighthouse/locales/zh-TW.json +0 -3
- package/front_end/third_party/lighthouse/locales/zh.json +0 -3
- package/front_end/third_party/lighthouse/report/bundle.d.ts +63 -61
- package/front_end/third_party/lighthouse/report/bundle.js +36 -7
- package/front_end/third_party/lighthouse/report-assets/report-generator.js +205 -192
- package/front_end/ui/components/diff_view/DiffView.ts +4 -4
- package/front_end/ui/components/helpers/component-server-setup.ts +1 -12
- package/front_end/ui/components/helpers/helpers.ts +0 -2
- package/front_end/ui/components/icon_button/IconButton.ts +1 -1
- package/front_end/ui/components/issue_counter/IssueCounter.ts +2 -2
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +3 -3
- package/front_end/ui/components/markdown_view/MarkdownView.ts +4 -4
- package/front_end/ui/components/panel_feedback/PreviewToggle.ts +98 -0
- package/front_end/ui/components/panel_feedback/panel_feedback.ts +1 -0
- package/front_end/ui/components/panel_feedback/previewToggle.css +24 -0
- package/front_end/ui/components/report_view/ReportView.ts +22 -0
- package/front_end/ui/components/report_view/reportSection.css +20 -0
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -1
- package/front_end/ui/components/settings/SettingCheckbox.ts +2 -2
- package/front_end/ui/components/text_editor/config.ts +9 -7
- package/front_end/ui/components/text_editor/javascript.ts +8 -4
- package/front_end/ui/components/text_prompt/TextPrompt.ts +2 -2
- package/front_end/ui/legacy/GlassPane.ts +1 -1
- package/front_end/ui/legacy/SearchableView.ts +2 -1
- package/front_end/ui/legacy/Treeoutline.ts +1 -1
- package/front_end/ui/legacy/Widget.ts +1 -1
- package/front_end/ui/legacy/XWidget.ts +0 -5
- package/front_end/ui/legacy/components/inline_editor/CSSVarSwatch.ts +2 -2
- package/front_end/ui/legacy/components/inline_editor/ColorSwatch.ts +1 -1
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +40 -32
- package/front_end/ui/legacy/themeColors.css +1 -1
- package/front_end/ui/legacy/utils/append-style.ts +2 -13
- package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +7 -5
- package/package.json +2 -4
- package/scripts/build/build_inspector_overlay.py +15 -1
- package/scripts/build/rjsmin.py +84 -115
- package/scripts/eslint_rules/lib/l10n_filename_matches.js +4 -4
- package/scripts/eslint_rules/lib/lit_html_no_attribute_quotes.js +101 -0
- package/scripts/eslint_rules/lib/no_only_eslint_tests.js +53 -0
- package/scripts/eslint_rules/tests/.eslintrc.js +14 -0
- package/scripts/eslint_rules/tests/l10n_filename_matches_test.js +4 -0
- package/scripts/eslint_rules/tests/lit_html_no_attribute_quotes_test.js +45 -0
- package/scripts/eslint_rules/tests/no_only_eslint_tests_test.js +94 -0
- package/front_end/entrypoints/devtools_app/devtools_app.js +0 -11
- package/front_end/entrypoints/devtools_app/devtools_app.json +0 -5
- package/front_end/entrypoints/inspector/inspector.json +0 -4
- package/front_end/entrypoints/js_app/js_app.js +0 -12
- package/front_end/entrypoints/js_app/js_app.json +0 -3
- package/front_end/entrypoints/ndb_app/ndb_app.json +0 -4
- package/front_end/entrypoints/startup/RuntimeInstantiator.ts +0 -95
- package/front_end/entrypoints/startup/startup.ts +0 -9
- package/front_end/entrypoints/worker_app/worker_app.json +0 -3
- package/front_end/panels/lighthouse/module.json +0 -6
- package/front_end/third_party/lighthouse/report-assets/report.d.ts +0 -1
- package/front_end/third_party/lighthouse/report-assets/report.js +0 -233
- package/front_end/third_party/lighthouse/report-assets/standalone-template.html +0 -38
- package/front_end/ui/components/helpers/get-stylesheet.ts +0 -45
- package/scripts/build/build_release_applications.py +0 -216
- package/scripts/build/modular_build.py +0 -184
- package/scripts/check_gn.js +0 -119
- package/scripts/json_validator/module.schema.json +0 -19
- package/scripts/json_validator/validate_module_json.js +0 -44
|
@@ -112,8 +112,9 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
|
112
112
|
private shouldAutoPrettyPrint: boolean;
|
|
113
113
|
private readonly progressToolbarItem: UI.Toolbar.ToolbarItem;
|
|
114
114
|
private textEditorInternal: TextEditor.TextEditor.TextEditor;
|
|
115
|
-
|
|
115
|
+
// The 'clean' document, before editing
|
|
116
116
|
private baseDoc: CodeMirror.Text;
|
|
117
|
+
private prettyBaseDoc: CodeMirror.Text|null = null;
|
|
117
118
|
private displayedSelection: CodeMirror.EditorSelection|null = null;
|
|
118
119
|
private searchConfig: UI.SearchableView.SearchConfig|null;
|
|
119
120
|
private delayedFindSearchMatches: (() => void)|null;
|
|
@@ -212,27 +213,7 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
|
212
213
|
TextEditor.Config.allowScrollPastEof.instance(),
|
|
213
214
|
TextEditor.Config.codeFolding.instance(),
|
|
214
215
|
TextEditor.Config.autoDetectIndent.instance(),
|
|
215
|
-
|
|
216
|
-
'&.cm-editor': {height: '100%'},
|
|
217
|
-
'.cm-scroller': {overflow: 'auto'},
|
|
218
|
-
'.cm-lineNumbers .cm-gutterElement.cm-nonBreakableLine': {color: 'var(--color-non-breakable-line)'},
|
|
219
|
-
'.cm-searchMatch': {
|
|
220
|
-
border: '1px solid var(--color-search-match-border)',
|
|
221
|
-
borderRadius: '3px',
|
|
222
|
-
margin: '0 -1px',
|
|
223
|
-
'&.cm-searchMatch-selected': {
|
|
224
|
-
borderRadius: '1px',
|
|
225
|
-
backgroundColor: 'var(--color-selected-search-match-background)',
|
|
226
|
-
borderColor: 'var(--color-selected-search-match-background)',
|
|
227
|
-
'&, & *': {
|
|
228
|
-
color: 'var(--color-selected-search-match) !important',
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
':host-context(.pretty-printed) & .cm-lineNumbers .cm-gutterElement': {
|
|
233
|
-
color: 'var(--legacy-accent-color)',
|
|
234
|
-
},
|
|
235
|
-
}),
|
|
216
|
+
sourceFrameTheme,
|
|
236
217
|
CodeMirror.EditorView.domEventHandlers({
|
|
237
218
|
focus: () => this.onFocus(),
|
|
238
219
|
blur: () => this.onBlur(),
|
|
@@ -352,6 +333,9 @@ export class SourceFrameImpl extends Common.ObjectWrapper.eventMixin<EventTypes,
|
|
|
352
333
|
this.updatePrettyPrintState();
|
|
353
334
|
}
|
|
354
335
|
|
|
336
|
+
// If this is a disassembled WASM file or a pretty-printed file,
|
|
337
|
+
// wire in a line number formatter that shows binary offsets or line
|
|
338
|
+
// numbers in the original source.
|
|
355
339
|
private getLineNumberFormatter(): CodeMirror.Extension {
|
|
356
340
|
if (this.options.lineNumbers === false) {
|
|
357
341
|
return [];
|
|
@@ -1099,18 +1083,20 @@ const searchHighlighter = CodeMirror.ViewPlugin.fromClass(class {
|
|
|
1099
1083
|
const {doc} = view.state;
|
|
1100
1084
|
for (const {from, to} of view.visibleRanges) {
|
|
1101
1085
|
let pos = from;
|
|
1102
|
-
for (const
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1086
|
+
for (const part of doc.iterRange(from, to)) {
|
|
1087
|
+
if (part !== '\n') {
|
|
1088
|
+
active.regexp.lastIndex = 0;
|
|
1089
|
+
for (;;) {
|
|
1090
|
+
const match = active.regexp.exec(part);
|
|
1091
|
+
if (!match) {
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
const start = pos + match.index, end = start + match[0].length;
|
|
1095
|
+
const current = active.currentRange && active.currentRange.from === start && active.currentRange.to === end;
|
|
1096
|
+
builder.add(start, end, current ? currentSearchMatchDeco : searchMatchDeco);
|
|
1108
1097
|
}
|
|
1109
|
-
const start = pos + match.index, end = start + match[0].length;
|
|
1110
|
-
const current = active.currentRange && active.currentRange.from === start && active.currentRange.to === end;
|
|
1111
|
-
builder.add(start, end, current ? currentSearchMatchDeco : searchMatchDeco);
|
|
1112
1098
|
}
|
|
1113
|
-
pos +=
|
|
1099
|
+
pos += part.length;
|
|
1114
1100
|
}
|
|
1115
1101
|
}
|
|
1116
1102
|
return builder.finish();
|
|
@@ -1163,3 +1149,25 @@ function markNonBreakableLines(disassembly: Common.WasmDisassembly.WasmDisassemb
|
|
|
1163
1149
|
return CodeMirror.RangeSet.of(marks);
|
|
1164
1150
|
});
|
|
1165
1151
|
}
|
|
1152
|
+
|
|
1153
|
+
const sourceFrameTheme = CodeMirror.EditorView.theme({
|
|
1154
|
+
'&.cm-editor': {height: '100%'},
|
|
1155
|
+
'.cm-scroller': {overflow: 'auto'},
|
|
1156
|
+
'.cm-lineNumbers .cm-gutterElement.cm-nonBreakableLine': {color: 'var(--color-non-breakable-line)'},
|
|
1157
|
+
'.cm-searchMatch': {
|
|
1158
|
+
border: '1px solid var(--color-search-match-border)',
|
|
1159
|
+
borderRadius: '3px',
|
|
1160
|
+
margin: '0 -1px',
|
|
1161
|
+
'&.cm-searchMatch-selected': {
|
|
1162
|
+
borderRadius: '1px',
|
|
1163
|
+
backgroundColor: 'var(--color-selected-search-match-background)',
|
|
1164
|
+
borderColor: 'var(--color-selected-search-match-background)',
|
|
1165
|
+
'&, & *': {
|
|
1166
|
+
color: 'var(--color-selected-search-match) !important',
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
},
|
|
1170
|
+
':host-context(.pretty-printed) & .cm-lineNumbers .cm-gutterElement': {
|
|
1171
|
+
color: 'var(--legacy-accent-color)',
|
|
1172
|
+
},
|
|
1173
|
+
});
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
--color-image-preview-background: rgb(255 255 255);
|
|
111
111
|
|
|
112
112
|
/* Colors for styling inputs */
|
|
113
|
-
--color-input-outline: rgb(
|
|
113
|
+
--color-input-outline: rgb(218 220 224);
|
|
114
114
|
--color-input-outline-active: rgb(26 115 232);
|
|
115
115
|
--color-input-outline-error: rgb(217 48 37);
|
|
116
116
|
--color-input-outline-disabled: rgba(128 134 139 / 20%);
|
|
@@ -2,19 +2,8 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function appendStyle(node: Node, cssReference: string|{cssContent: string}): void {
|
|
8
|
-
let content: string;
|
|
9
|
-
if (typeof cssReference === 'string') {
|
|
10
|
-
content = Root.Runtime.cachedResources.get(cssReference) || '';
|
|
11
|
-
if (!content) {
|
|
12
|
-
console.error(cssReference + ' not preloaded. Check module.json');
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
content = cssReference.cssContent;
|
|
16
|
-
}
|
|
5
|
+
export function appendStyle(node: Node, {cssContent}: {cssContent: string}): void {
|
|
17
6
|
const styleElement = document.createElement('style');
|
|
18
|
-
styleElement.textContent =
|
|
7
|
+
styleElement.textContent = cssContent;
|
|
19
8
|
node.appendChild(styleElement);
|
|
20
9
|
}
|
|
@@ -7,7 +7,7 @@ import {focusChanged} from './focus-changed.js';
|
|
|
7
7
|
import {injectCoreStyles} from './inject-core-styles.js';
|
|
8
8
|
|
|
9
9
|
interface Options {
|
|
10
|
-
cssFile?:
|
|
10
|
+
cssFile?: CSSStyleSheet[]|{cssContent: string};
|
|
11
11
|
delegatesFocus?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -22,10 +22,12 @@ export function createShadowRootWithCoreStyles(element: Element, options: Option
|
|
|
22
22
|
|
|
23
23
|
const shadowRoot = element.attachShadow({mode: 'open', delegatesFocus});
|
|
24
24
|
injectCoreStyles(shadowRoot);
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (cssFile) {
|
|
26
|
+
if ('cssContent' in cssFile) {
|
|
27
|
+
appendStyle(shadowRoot, cssFile);
|
|
28
|
+
} else {
|
|
29
|
+
shadowRoot.adoptedStyleSheets = cssFile;
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
shadowRoot.addEventListener('focus', focusChanged, true);
|
|
31
33
|
return shadowRoot;
|
package/package.json
CHANGED
|
@@ -27,10 +27,8 @@
|
|
|
27
27
|
"auto-unittest": "scripts/test/run_auto_unittests.py --no-text-coverage",
|
|
28
28
|
"build": "autoninja -C out/Default",
|
|
29
29
|
"build-release": "autoninja -C out/Release",
|
|
30
|
-
"check": "npm run check-
|
|
30
|
+
"check": "npm run check-lint && npm run check-loc",
|
|
31
31
|
"check-external-links": "third_party/node/node.py --output scripts/check_external_links.js",
|
|
32
|
-
"check-gn": "third_party/node/node.py --output scripts/check_gn.js",
|
|
33
|
-
"check-json": "third_party/node/node.py --output scripts/json_validator/validate_module_json.js",
|
|
34
32
|
"check-lint": "third_party/node/node.py --output scripts/test/run_lint_check_js.mjs && third_party/node/node.py --output scripts/test/run_lint_check_css.js",
|
|
35
33
|
"check-lint-css": "third_party/node/node.py --output scripts/test/run_lint_check_css.js",
|
|
36
34
|
"collect-strings": "third_party/node/node.py --output third_party/i18n/collect-strings.js front_end",
|
|
@@ -55,5 +53,5 @@
|
|
|
55
53
|
"unittest": "scripts/test/run_unittests.py --no-text-coverage",
|
|
56
54
|
"watch": "third_party/node/node.py --output scripts/watch_build.js"
|
|
57
55
|
},
|
|
58
|
-
"version": "1.0.
|
|
56
|
+
"version": "1.0.948445"
|
|
59
57
|
}
|
|
@@ -12,7 +12,6 @@ Builds inspector overlay:
|
|
|
12
12
|
|
|
13
13
|
from os import path
|
|
14
14
|
from os.path import join
|
|
15
|
-
from modular_build import read_file, write_file
|
|
16
15
|
from itertools import tee
|
|
17
16
|
|
|
18
17
|
import os
|
|
@@ -29,6 +28,21 @@ finally:
|
|
|
29
28
|
sys.path = original_sys_path
|
|
30
29
|
|
|
31
30
|
|
|
31
|
+
def read_file(filename):
|
|
32
|
+
with open(path.normpath(filename), 'rt', encoding='utf-8') as input:
|
|
33
|
+
return input.read()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def write_file(filename, content):
|
|
37
|
+
if path.exists(filename):
|
|
38
|
+
os.remove(filename)
|
|
39
|
+
directory = path.dirname(filename)
|
|
40
|
+
if not path.exists(directory):
|
|
41
|
+
os.makedirs(directory)
|
|
42
|
+
with open(filename, 'wt', encoding='utf-8') as output:
|
|
43
|
+
output.write(content)
|
|
44
|
+
|
|
45
|
+
|
|
32
46
|
def check_size(filename, data, max_size):
|
|
33
47
|
assert len(
|
|
34
48
|
data
|
package/scripts/build/rjsmin.py
CHANGED
|
@@ -119,8 +119,7 @@ def _make_jsmin(python_only=False):
|
|
|
119
119
|
charclass = r'(?:\[[^\\\]\r\n]*(?:\\[^\r\n][^\\\]\r\n]*)*\])'
|
|
120
120
|
nospecial = r'[^/\\\[\r\n]'
|
|
121
121
|
regex = r'(?:/(?![\r\n/*])%s*(?:(?:\\[^\r\n]|%s)%s*)*/)' % (
|
|
122
|
-
nospecial, charclass, nospecial
|
|
123
|
-
)
|
|
122
|
+
nospecial, charclass, nospecial)
|
|
124
123
|
space = r'(?:%s|%s)' % (space_chars, space_comment)
|
|
125
124
|
newline = r'(?:%s?[\r\n])' % line_comment
|
|
126
125
|
|
|
@@ -147,36 +146,28 @@ def _make_jsmin(python_only=False):
|
|
|
147
146
|
first = last = char
|
|
148
147
|
if last is not None:
|
|
149
148
|
result.append((first, last))
|
|
150
|
-
return ''.join([
|
|
151
|
-
chr(first),
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
return ''.join([
|
|
150
|
+
'%s%s%s' % (chr(first), last > first + 1 and '-'
|
|
151
|
+
or '', last != first and chr(last) or '')
|
|
152
|
+
for first, last in result
|
|
153
|
+
]) # noqa
|
|
155
154
|
|
|
156
155
|
return _re.sub(
|
|
157
156
|
r'([\000-\040\047])', # \047 for better portability
|
|
158
|
-
lambda m: '\\%03o' % ord(m.group(1)),
|
|
159
|
-
|
|
160
|
-
.replace('
|
|
161
|
-
.replace('[', '\\[')
|
|
162
|
-
.replace(']', '\\]')
|
|
163
|
-
)
|
|
164
|
-
)
|
|
157
|
+
lambda m: '\\%03o' % ord(m.group(1)),
|
|
158
|
+
(sequentize(result).replace('\\', '\\\\').replace(
|
|
159
|
+
'[', '\\[').replace(']', '\\]')))
|
|
165
160
|
|
|
166
161
|
def id_literal_(what):
|
|
167
162
|
""" Make id_literal like char class """
|
|
168
163
|
match = _re.compile(what).match
|
|
169
|
-
result = ''.join([
|
|
170
|
-
chr(c) for c in xrange(127) if not match(chr(c))
|
|
171
|
-
])
|
|
164
|
+
result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
|
|
172
165
|
return '[^%s]' % fix_charclass(result)
|
|
173
166
|
|
|
174
167
|
def not_id_literal_(keep):
|
|
175
168
|
""" Make negated id_literal like char class """
|
|
176
169
|
match = _re.compile(id_literal_(keep)).match
|
|
177
|
-
result = ''.join([
|
|
178
|
-
chr(c) for c in xrange(127) if not match(chr(c))
|
|
179
|
-
])
|
|
170
|
+
result = ''.join([chr(c) for c in xrange(127) if not match(chr(c))])
|
|
180
171
|
return r'[%s]' % fix_charclass(result)
|
|
181
172
|
|
|
182
173
|
not_id_literal = not_id_literal_(r'[a-zA-Z0-9_$]')
|
|
@@ -192,28 +183,26 @@ def _make_jsmin(python_only=False):
|
|
|
192
183
|
|
|
193
184
|
space_sub_simple = _re.compile((
|
|
194
185
|
# noqa pylint: disable = bad-continuation
|
|
195
|
-
|
|
196
|
-
r'(%(dull)s
|
|
197
|
-
r'|(%(strings)s%(dull)s*)' # 1
|
|
186
|
+
r'(%(dull)s+)' # 0
|
|
187
|
+
r'|(%(strings)s%(dull)s*)' # 1
|
|
198
188
|
r'|(?<=%(preregex1)s)'
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
189
|
+
r'%(space)s*(?:%(newline)s%(space)s*)*'
|
|
190
|
+
r'(%(regex)s)' # 2
|
|
191
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 3
|
|
192
|
+
r'(?=%(post_regex_off)s))?'
|
|
203
193
|
r'|(?<=%(preregex2)s)'
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
r'%(space)s*(?:(%(newline)s)%(space)s*)*' # 4
|
|
195
|
+
r'(%(regex)s)' # 5
|
|
196
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 6
|
|
197
|
+
r'(?=%(post_regex_off)s))?'
|
|
208
198
|
r'|(?<=%(id_literal_close)s)'
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
r'%(space)s*(?:(%(newline)s)%(space)s*)+' # 7
|
|
200
|
+
r'(?=%(id_literal_open)s)'
|
|
211
201
|
r'|(?<=%(id_literal)s)(%(space)s)+(?=%(id_literal)s)' # 8
|
|
212
|
-
r'|(?<=\+)(%(space)s)+(?=\+)'
|
|
213
|
-
r'|(?<=-)(%(space)s)+(?=-)'
|
|
202
|
+
r'|(?<=\+)(%(space)s)+(?=\+)' # 9
|
|
203
|
+
r'|(?<=-)(%(space)s)+(?=-)' # 10
|
|
214
204
|
r'|%(space)s+'
|
|
215
|
-
r'|(?:%(newline)s%(space)s*)+'
|
|
216
|
-
) % locals()).sub
|
|
205
|
+
r'|(?:%(newline)s%(space)s*)+') % locals()).sub
|
|
217
206
|
|
|
218
207
|
# print space_sub_simple.__self__.pattern
|
|
219
208
|
|
|
@@ -245,35 +234,33 @@ def _make_jsmin(python_only=False):
|
|
|
245
234
|
|
|
246
235
|
space_sub_banged = _re.compile((
|
|
247
236
|
# noqa pylint: disable = bad-continuation
|
|
248
|
-
|
|
249
|
-
r'(%(dull)s
|
|
250
|
-
r'|(%(strings)s%(dull)s*)' # 1
|
|
237
|
+
r'(%(dull)s+)' # 0
|
|
238
|
+
r'|(%(strings)s%(dull)s*)' # 1
|
|
251
239
|
r'|(?<=%(preregex1)s)'
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
240
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)*)' # 2
|
|
241
|
+
r'(%(regex)s)' # 3
|
|
242
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 4
|
|
243
|
+
r'(?=%(post_regex_off)s))?'
|
|
256
244
|
r'|(?<=%(preregex2)s)'
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
245
|
+
r'(%(space)s*(?:(%(newline)s)%(space)s*)*)' # 5, 6
|
|
246
|
+
r'(%(regex)s)' # 7
|
|
247
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+' # 8
|
|
248
|
+
r'(?=%(post_regex_off)s))?'
|
|
261
249
|
r'|(?<=%(id_literal_close)s)'
|
|
262
|
-
|
|
263
|
-
|
|
250
|
+
r'(%(space)s*(?:%(newline)s%(space)s*)+)' # 9
|
|
251
|
+
r'(?=%(id_literal_open)s)'
|
|
264
252
|
r'|(?<=%(id_literal)s)(%(space)s+)(?=%(id_literal)s)' # 10
|
|
265
|
-
r'|(?<=\+)(%(space)s+)(?=\+)'
|
|
266
|
-
r'|(?<=-)(%(space)s+)(?=-)'
|
|
267
|
-
r'|(%(space)s+)'
|
|
268
|
-
r'|((?:%(newline)s%(space)s*)+)'
|
|
253
|
+
r'|(?<=\+)(%(space)s+)(?=\+)' # 11
|
|
254
|
+
r'|(?<=-)(%(space)s+)(?=-)' # 12
|
|
255
|
+
r'|(%(space)s+)' # 13
|
|
256
|
+
r'|((?:%(newline)s%(space)s*)+)' # 14
|
|
269
257
|
) % locals()).sub
|
|
270
258
|
|
|
271
259
|
# print space_sub_banged.__self__.pattern
|
|
272
260
|
|
|
273
|
-
keep = _re.compile(
|
|
274
|
-
r'%(space_chars)s+|%(space_comment_nobang)s+|%(newline)s+'
|
|
275
|
-
|
|
276
|
-
) % locals()).sub
|
|
261
|
+
keep = _re.compile(
|
|
262
|
+
(r'%(space_chars)s+|%(space_comment_nobang)s+|%(newline)s+'
|
|
263
|
+
r'|(%(bang_comment)s+)') % locals()).sub
|
|
277
264
|
keeper = lambda m: m.groups()[0] or ''
|
|
278
265
|
|
|
279
266
|
# print keep.__self__.pattern
|
|
@@ -333,16 +320,15 @@ def _make_jsmin(python_only=False):
|
|
|
333
320
|
# pylint: disable = redefined-outer-name
|
|
334
321
|
|
|
335
322
|
if keep_bang_comments:
|
|
336
|
-
return space_sub_banged(
|
|
337
|
-
|
|
338
|
-
).strip()
|
|
323
|
+
return space_sub_banged(space_subber_banged,
|
|
324
|
+
'\n%s\n' % script).strip()
|
|
339
325
|
else:
|
|
340
|
-
return space_sub_simple(
|
|
341
|
-
|
|
342
|
-
).strip()
|
|
326
|
+
return space_sub_simple(space_subber_simple,
|
|
327
|
+
'\n%s\n' % script).strip()
|
|
343
328
|
|
|
344
329
|
return jsmin
|
|
345
330
|
|
|
331
|
+
|
|
346
332
|
jsmin = _make_jsmin()
|
|
347
333
|
|
|
348
334
|
|
|
@@ -403,28 +389,19 @@ def jsmin_for_posers(script, keep_bang_comments=False):
|
|
|
403
389
|
r'\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)))+(?=-)|(?:['
|
|
404
390
|
r'\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)'
|
|
405
391
|
r')+|(?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014\016-\040]'
|
|
406
|
-
r'|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+'
|
|
407
|
-
)
|
|
392
|
+
r'|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+')
|
|
408
393
|
|
|
409
394
|
def subber(match):
|
|
410
395
|
""" Substitution callback """
|
|
411
396
|
groups = match.groups()
|
|
412
|
-
return (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
groups[
|
|
419
|
-
groups[
|
|
420
|
-
groups[6] and '\n' or '',
|
|
421
|
-
)) or
|
|
422
|
-
(groups[7] and '\n') or
|
|
423
|
-
(groups[8] and ' ') or
|
|
424
|
-
(groups[9] and ' ') or
|
|
425
|
-
(groups[10] and ' ') or
|
|
426
|
-
''
|
|
427
|
-
)
|
|
397
|
+
return (groups[0] or groups[1]
|
|
398
|
+
or (groups[3] and (groups[2] + '\n')) or groups[2]
|
|
399
|
+
or (groups[5] and "%s%s%s" % (
|
|
400
|
+
groups[4] and '\n' or '',
|
|
401
|
+
groups[5],
|
|
402
|
+
groups[6] and '\n' or '',
|
|
403
|
+
)) or (groups[7] and '\n') or (groups[8] and ' ')
|
|
404
|
+
or (groups[9] and ' ') or (groups[10] and ' ') or '')
|
|
428
405
|
else:
|
|
429
406
|
rex = (
|
|
430
407
|
r'([^\047"/\000-\040]+)|((?:(?:\047[^\047\\\r\n]*(?:\\(?:[^\r\n]'
|
|
@@ -457,46 +434,39 @@ def jsmin_for_posers(script, keep_bang_comments=False):
|
|
|
457
434
|
r'11\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))+)(?=-'
|
|
458
435
|
r')|((?:[\000-\011\013\014\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*'
|
|
459
436
|
r'\*+)*/))+)|((?:(?:(?://[^\r\n]*)?[\r\n])(?:[\000-\011\013\014'
|
|
460
|
-
r'\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+)'
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
r'*]*\*+)*/)+)'
|
|
467
|
-
) % locals()).sub
|
|
437
|
+
r'\016-\040]|(?:/\*[^*]*\*+(?:[^/*][^*]*\*+)*/))*)+)')
|
|
438
|
+
|
|
439
|
+
keep = _re.compile(
|
|
440
|
+
(r'[\000-\011\013\014\016-\040]+|(?:/\*(?!!)[^*]*\*+(?:[^/*][^*]*'
|
|
441
|
+
r'\*+)*/)+|(?:(?://[^\r\n]*)?[\r\n])+|((?:/\*![^*]*\*+(?:[^/*][^'
|
|
442
|
+
r'*]*\*+)*/)+)') % locals()).sub
|
|
468
443
|
keeper = lambda m: m.groups()[0] or ''
|
|
469
444
|
|
|
470
445
|
def subber(match):
|
|
471
446
|
""" Substitution callback """
|
|
472
447
|
groups = match.groups()
|
|
473
|
-
return (
|
|
474
|
-
groups[
|
|
475
|
-
groups[
|
|
476
|
-
(groups[
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
(groups[
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
groups[
|
|
486
|
-
keep(keeper, groups[
|
|
487
|
-
groups[
|
|
488
|
-
|
|
489
|
-
(groups[9] and keep(keeper, groups[9] + '\n')) or
|
|
490
|
-
(groups[10] and keep(keeper, groups[10]) or ' ') or
|
|
491
|
-
(groups[11] and keep(keeper, groups[11]) or ' ') or
|
|
492
|
-
(groups[12] and keep(keeper, groups[12]) or ' ') or
|
|
493
|
-
keep(keeper, groups[13] or groups[14])
|
|
494
|
-
)
|
|
448
|
+
return (groups[0] or groups[1] or (groups[3] and "%s%s%s%s" % (
|
|
449
|
+
keep(keeper, groups[2]),
|
|
450
|
+
groups[3],
|
|
451
|
+
keep(keeper, groups[4] or ''),
|
|
452
|
+
groups[4] and '\n' or '',
|
|
453
|
+
)) or (groups[7] and "%s%s%s%s%s" % (
|
|
454
|
+
keep(keeper, groups[5]),
|
|
455
|
+
groups[6] and '\n' or '',
|
|
456
|
+
groups[7],
|
|
457
|
+
keep(keeper, groups[8] or ''),
|
|
458
|
+
groups[8] and '\n' or '',
|
|
459
|
+
)) or (groups[9] and keep(keeper, groups[9] + '\n'))
|
|
460
|
+
or (groups[10] and keep(keeper, groups[10]) or ' ')
|
|
461
|
+
or (groups[11] and keep(keeper, groups[11]) or ' ')
|
|
462
|
+
or (groups[12] and keep(keeper, groups[12]) or ' ')
|
|
463
|
+
or keep(keeper, groups[13] or groups[14]))
|
|
495
464
|
|
|
496
465
|
return _re.sub(rex, subber, '\n%s\n' % script).strip()
|
|
497
466
|
|
|
498
467
|
|
|
499
468
|
if __name__ == '__main__':
|
|
469
|
+
|
|
500
470
|
def main():
|
|
501
471
|
""" Main """
|
|
502
472
|
import sys as _sys
|
|
@@ -508,8 +478,7 @@ if __name__ == '__main__':
|
|
|
508
478
|
else:
|
|
509
479
|
xjsmin = jsmin
|
|
510
480
|
|
|
511
|
-
_sys.stdout.write(
|
|
512
|
-
_sys.stdin.read(), keep_bang_comments=keep_bang_comments
|
|
513
|
-
))
|
|
481
|
+
_sys.stdout.write(
|
|
482
|
+
xjsmin(_sys.stdin.read(), keep_bang_comments=keep_bang_comments))
|
|
514
483
|
|
|
515
484
|
main()
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
const path = require('path');
|
|
8
|
-
const {devtoolsRootPath} = require('../../devtools_paths.js');
|
|
9
|
-
|
|
10
|
-
const DEFAULT_FRONT_END_DIRECTORY = path.join(devtoolsRootPath(), 'front_end');
|
|
11
8
|
|
|
12
9
|
function isModuleScope(context) {
|
|
13
10
|
return context.getScope().type === 'module';
|
|
@@ -60,10 +57,13 @@ module.exports = {
|
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
let frontEndDirectory =
|
|
60
|
+
let frontEndDirectory = '';
|
|
64
61
|
if (context.options && context.options[0]?.rootFrontendDirectory) {
|
|
65
62
|
frontEndDirectory = context.options[0].rootFrontendDirectory;
|
|
66
63
|
}
|
|
64
|
+
if (!frontEndDirectory) {
|
|
65
|
+
throw new Error('rootFrontendDirectory must be provided.');
|
|
66
|
+
}
|
|
67
67
|
const currentSourceFile = path.resolve(context.getFilename());
|
|
68
68
|
const currentFileRelativeToFrontEnd = path.relative(frontEndDirectory, currentSourceFile);
|
|
69
69
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
function isLitHtmlTemplateCall(taggedTemplateExpressionNode) {
|
|
7
|
+
// Match LitHtml.html``
|
|
8
|
+
const {tag} = taggedTemplateExpressionNode;
|
|
9
|
+
if (!tag) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
// Match LitHtml.html``
|
|
13
|
+
const isLitHtmlDotHtmlCall = tag.object?.name === 'LitHtml' && tag.property?.name === 'html';
|
|
14
|
+
// Match html`` (and guess that it's Lit)
|
|
15
|
+
const isDestructuredHtmlCall = tag.type === 'Identifier' && tag.name === 'html';
|
|
16
|
+
|
|
17
|
+
return isLitHtmlDotHtmlCall || isDestructuredHtmlCall;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function templateElementPartStartsWithDoubleQuote(templateElementPartNode) {
|
|
21
|
+
return templateElementPartNode.value.raw.startsWith('"');
|
|
22
|
+
}
|
|
23
|
+
function templateElementPartEndsWithEqualsDoubleQuote(templateElementPartNode) {
|
|
24
|
+
return templateElementPartNode.value.raw.endsWith('="');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function removeQuotesFromAttribute({fixer, firstPart, secondPart}) {
|
|
28
|
+
const [, rangeOfOpeningTemplatePartEnd] = firstPart.range;
|
|
29
|
+
// From the first part, we need to remove the last character, which is the double quote.
|
|
30
|
+
// We can do this by fetching the range of the node (range = start and end position on the line)
|
|
31
|
+
// However, for the template part with the opening quote, the range will also contain the ${ of the interpolation:
|
|
32
|
+
// <p class="${
|
|
33
|
+
// ^^^^^^^^^^^^ this is the text covered by the [start, end] range.
|
|
34
|
+
// So what we need to do is remove the quote, and leave the last two characters alone.
|
|
35
|
+
// Therefore we remove the third character back from the end, and only remove a single character, leaving the ${ part alone.
|
|
36
|
+
const startingQuoteRangeToRemove = [rangeOfOpeningTemplatePartEnd - 3, rangeOfOpeningTemplatePartEnd - 2];
|
|
37
|
+
|
|
38
|
+
const [rangeOfClosingTemplatePartStart] = secondPart.range;
|
|
39
|
+
// It's a similar story for the second part where the range includes the }:
|
|
40
|
+
// }">foo</p>
|
|
41
|
+
// ^^^^^^^^^^ this is the range
|
|
42
|
+
// So therefore we get the start of the range, and add one to it, to dodge the } character, and then remove only the quote.
|
|
43
|
+
const endingQuoteRangeToRemove = [rangeOfClosingTemplatePartStart + 1, rangeOfClosingTemplatePartStart + 2];
|
|
44
|
+
|
|
45
|
+
return [fixer.removeRange(startingQuoteRangeToRemove), fixer.removeRange(endingQuoteRangeToRemove)];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
meta: {
|
|
50
|
+
type: 'problem',
|
|
51
|
+
|
|
52
|
+
docs: {
|
|
53
|
+
description: 'ensure no extra quotes around attributes when the value is interpolated',
|
|
54
|
+
category: 'Possible Errors',
|
|
55
|
+
},
|
|
56
|
+
fixable: 'code',
|
|
57
|
+
messages: {
|
|
58
|
+
attributeQuotesNotRequired:
|
|
59
|
+
'When interpolating a value as an attribute in LitHtml you do not need double quotes around it.',
|
|
60
|
+
},
|
|
61
|
+
schema: [] // no options
|
|
62
|
+
},
|
|
63
|
+
create: function(context) {
|
|
64
|
+
return {
|
|
65
|
+
TaggedTemplateExpression(node) {
|
|
66
|
+
if (!isLitHtmlTemplateCall(node)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// quasis here = the static parts of a template expression
|
|
71
|
+
// expressions = the dynamic parts of a template expression
|
|
72
|
+
// For example, given: <p class="${foo}"> we will have:
|
|
73
|
+
// quasis: ['<p class="', '">']
|
|
74
|
+
// expressions: ['foo'] (it's actually an AST node representing ${foo})
|
|
75
|
+
// So what we do is walk through and look for quasi pairs where:
|
|
76
|
+
// 1. the first ends with ="
|
|
77
|
+
// 2. the second begins with "
|
|
78
|
+
// We can then be confident that we have found an attribute with quotes around it.
|
|
79
|
+
node.quasi.quasis.forEach((templateElement, index) => {
|
|
80
|
+
if (templateElementPartEndsWithEqualsDoubleQuote(templateElement)) {
|
|
81
|
+
const nextElement = node.quasi.quasis[index + 1];
|
|
82
|
+
if (nextElement && templateElementPartStartsWithDoubleQuote(nextElement)) {
|
|
83
|
+
const expressionBetweenTheParts = node.quasi.expressions[index];
|
|
84
|
+
context.report({
|
|
85
|
+
node: expressionBetweenTheParts,
|
|
86
|
+
messageId: 'attributeQuotesNotRequired',
|
|
87
|
+
fix(fixer) {
|
|
88
|
+
return removeQuotesFromAttribute({
|
|
89
|
+
fixer,
|
|
90
|
+
firstPart: templateElement,
|
|
91
|
+
secondPart: nextElement,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|