MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / setStyleSheetText

Method setStyleSheetText

front_end/core/sdk/CSSModel.ts:827–851  ·  view source on GitHub ↗
(styleSheetId: Protocol.DOM.StyleSheetId, newText: string, majorChange: boolean)

Source from the content-addressed store, hash-verified

825 }
826
827 async setStyleSheetText(styleSheetId: Protocol.DOM.StyleSheetId, newText: string, majorChange: boolean):
828 Promise<string|null> {
829 const header = this.#styleSheetIdToHeader.get(styleSheetId);
830 if (!header) {
831 return 'Unknown stylesheet in CSS.setStyleSheetText';
832 }
833 newText = CSSModel.trimSourceURL(newText);
834 if (header.hasSourceURL) {
835 newText += '\n/*# sourceURL=' + header.sourceURL + ' */';
836 }
837
838 await this.ensureOriginalStyleSheetText(styleSheetId);
839 const response = await this.agent.invoke_setStyleSheetText({styleSheetId: header.id, text: newText});
840 const sourceMapURL = response.sourceMapURL as Platform.DevToolsPath.UrlString;
841
842 this.#sourceMapManager.detachSourceMap(header);
843 header.setSourceMapURL(sourceMapURL);
844 this.#sourceMapManager.attachSourceMap(header, header.sourceURL, header.sourceMapURL);
845 if (sourceMapURL === null) {
846 return 'Error in CSS.setStyleSheetText';
847 }
848 this.#domModel.markUndoableState(!majorChange);
849 this.fireStyleSheetChanged(styleSheetId);
850 return null;
851 }
852
853 async getStyleSheetText(styleSheetId: Protocol.DOM.StyleSheetId): Promise<string|null> {
854 const response = await this.agent.invoke_getStyleSheetText({styleSheetId});

Callers 7

toggleEmulatedOverlayMethod · 0.80
editingCommittedMethod · 0.80
handleNodeInsertedMethod · 0.80
stashChangesMethod · 0.80
addChangeMethod · 0.80
#onCssModelDisposedMethod · 0.80
mirrorContentMethod · 0.80

Calls 9

fireStyleSheetChangedMethod · 0.95
trimSourceURLMethod · 0.80
detachSourceMapMethod · 0.80
attachSourceMapMethod · 0.80
getMethod · 0.65
setSourceMapURLMethod · 0.45
markUndoableStateMethod · 0.45

Tested by

no test coverage detected