@@ -182,7 +182,7 @@ defmodule Phoenix.LiveView.ColocatedCSS do
182182 { scope , data } = extract ( opts , text_content , meta )
183183
184184 # we always drop colocated CSS from the rendered output
185- { :ok , "" , data , [ root_tag_attribute: { "phx-css" , scope } ] }
185+ { :ok , "" , data , [ root_tag_attribute: { "phx-css- #{ scope } " , true } ] }
186186 end
187187
188188 def transform ( _ast , _meta ) do
@@ -192,9 +192,8 @@ defmodule Phoenix.LiveView.ColocatedCSS do
192192 defp validate_phx_version! do
193193 phoenix_version = to_string ( Application . spec ( :phoenix , :vsn ) )
194194
195- if not Version . match? ( phoenix_version , "~> 1.8.0-rc.4" ) do
196- # TODO: bump message to 1.8 once released to avoid confusion
197- raise ArgumentError , ~s| ColocatedCSS requires at least {:phoenix, "~> 1.8.0-rc.4"}|
195+ if not Version . match? ( phoenix_version , "~> 1.8.0" ) do
196+ raise ArgumentError , ~s| ColocatedCSS requires at least {:phoenix, "~> 1.8.0"}|
198197 end
199198 end
200199
@@ -234,10 +233,10 @@ defmodule Phoenix.LiveView.ColocatedCSS do
234233 # _build/dev/phoenix-colocated-css/otp_app/MyApp.MyComponent/line_no.css
235234 target_path = Path . join ( target_dir ( ) , inspect ( meta . env . module ) )
236235
237- scope = scope ( meta )
236+ scope = scope ( text_content , meta )
238237 root_tag_attribute = root_tag_attribute ( )
239238
240- upper_bound_selector = ~s| [phx-css=" #{ scope } " ]|
239+ upper_bound_selector = ~s| [phx-css- #{ scope } ]|
241240 lower_bound_selector = ~s| [#{ root_tag_attribute } ]|
242241
243242 lower_bound_selector =
@@ -266,11 +265,15 @@ defmodule Phoenix.LiveView.ColocatedCSS do
266265 { scope , filename }
267266 end
268267
269- defp scope ( meta ) do
270- hash ( "#{ meta . env . module } _#{ meta . env . line } " )
268+ defp scope ( text_content , meta ) do
269+ hash ( "#{ meta . env . module } _#{ meta . env . line } : #{ text_content } " )
271270 end
272271
273272 defp hash ( string ) do
273+ # It is important that we do not pad
274+ # the Base32 encoded value as we use it in
275+ # an HTML attribute name and = (the padding character)
276+ # is not valid.
274277 string
275278 |> then ( & :crypto . hash ( :md5 , & 1 ) )
276279 |> Base . encode32 ( case: :lower , padding: false )
0 commit comments