@@ -34,6 +34,7 @@ define(function (require, exports, module) {
3434 _ = require ( "thirdparty/lodash" ) ,
3535 LiveDocument = require ( "LiveDevelopment/MultiBrowserImpl/documents/LiveDocument" ) ,
3636 HTMLInstrumentation = require ( "LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation" ) ,
37+ HTMLUtils = require ( "language/HTMLUtils" ) ,
3738 CSSUtils = require ( "language/CSSUtils" ) ;
3839
3940 /**
@@ -161,19 +162,28 @@ define(function (require, exports, module) {
161162 selectors = [ ] ;
162163
163164 // check if the cursor is in a stylesheet context (internal styles)
165+ // but skip CSS selector lookup for inline style attributes (style="...")
166+ // since they have no selector — the element itself should be highlighted instead
164167 if ( mode === "css" || mode === "text/x-scss" || mode === "text/x-less" ) {
165- // find the css selector
166- _ . each ( this . editor . getSelections ( ) , function ( sel ) {
167- let selector = CSSUtils . findSelectorAtDocumentPos ( editor , ( sel . reversed ? sel . end : sel . start ) ) ;
168- if ( selector ) {
169- selectors . push ( selector ) ;
170- }
171- } ) ;
168+ var primarySel = editor . getSelection ( ) ;
169+ var tagInfo = HTMLUtils . getTagInfo ( editor , primarySel . start , true ) ;
170+ var isInlineStyle = tagInfo . position . tokenType === HTMLUtils . ATTR_VALUE &&
171+ tagInfo . attr . name . toLowerCase ( ) === "style" ;
172+
173+ if ( ! isInlineStyle ) {
174+ // find the css selector
175+ _ . each ( this . editor . getSelections ( ) , function ( sel ) {
176+ let selector = CSSUtils . findSelectorAtDocumentPos ( editor , ( sel . reversed ? sel . end : sel . start ) ) ;
177+ if ( selector ) {
178+ selectors . push ( selector ) ;
179+ }
180+ } ) ;
172181
173- if ( selectors . length ) {
174- // to highlight the elements that match the css selectors
175- this . highlightRule ( selectors . join ( "," ) ) ;
176- return ;
182+ if ( selectors . length ) {
183+ // to highlight the elements that match the css selectors
184+ this . highlightRule ( selectors . join ( "," ) ) ;
185+ return ;
186+ }
177187 }
178188 }
179189
0 commit comments