Title: [274230] trunk/Source/WebInspectorUI
Revision
274230
Author
nvasil...@apple.com
Date
2021-03-10 12:43:35 -0800 (Wed, 10 Mar 2021)

Log Message

Web Inspector: Syntax highlighting for JSX is incorrect
https://bugs.webkit.org/show_bug.cgi?id=217613
<rdar://problem/70210975>

Reviewed by BJ Burg.

Out of the box, React specifies the "js" extension for JSX files.
Use JSX mode for source map resources with the "js" extension. This
appears to match what the other browsers' developer tools do.

* UserInterface/Models/SourceMapResource.js:
(WI.SourceMapResource):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (274229 => 274230)


--- trunk/Source/WebInspectorUI/ChangeLog	2021-03-10 20:36:30 UTC (rev 274229)
+++ trunk/Source/WebInspectorUI/ChangeLog	2021-03-10 20:43:35 UTC (rev 274230)
@@ -1,3 +1,18 @@
+2021-03-10  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Syntax highlighting for JSX is incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=217613
+        <rdar://problem/70210975>
+
+        Reviewed by BJ Burg.
+
+        Out of the box, React specifies the "js" extension for JSX files.
+        Use JSX mode for source map resources with the "js" extension. This
+        appears to match what the other browsers' developer tools do.
+
+        * UserInterface/Models/SourceMapResource.js:
+        (WI.SourceMapResource):
+
 2021-03-10  Razvan Caliman  <rcali...@apple.com>
 
         Web Inspector: CSS Grid Inspector clean-up

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js (274229 => 274230)


--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2021-03-10 20:36:30 UTC (rev 274229)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2021-03-10 20:43:35 UTC (rev 274230)
@@ -36,9 +36,11 @@
 
         var inheritedMIMEType = this._sourceMap.originalSourceCode instanceof WI.Resource ? this._sourceMap.originalSourceCode.syntheticMIMEType : null;
 
-        var fileExtension = WI.fileExtensionForURL(url) || "";
-        var fileExtensionMIMEType = WI.mimeTypeForFileExtension(fileExtension, true);
+        let fileExtension = WI.fileExtensionForURL(url) || "";
 
+        // React serves JSX resources with "js" extension.
+        let fileExtensionMIMEType = fileExtension === "js" ? "text/jsx" : WI.mimeTypeForFileExtension(fileExtension, true);
+
         // FIXME: This is a layering violation. It should use a helper function on the
         // Resource base-class to set _mimeType and _type.
         this._mimeType = fileExtensionMIMEType || inheritedMIMEType || "text/_javascript_";
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to