Skip to content

Commit

Permalink
Element text selector: Normalize whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ftes committed Jan 9, 2025
1 parent 01423d0 commit fc7272a
Show file tree
Hide file tree
Showing 49 changed files with 643 additions and 458 deletions.
16 changes: 12 additions & 4 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ if Mix.env() == :dev do

config :esbuild,
version: "0.12.15",
module: esbuild.(~w(--format=esm --sourcemap --outfile=../priv/static/phoenix_live_view.esm.js)),
main: esbuild.(~w(--format=cjs --sourcemap --outfile=../priv/static/phoenix_live_view.cjs.js)),
cdn: esbuild.(~w(--format=iife --target=es2016 --global-name=LiveView --outfile=../priv/static/phoenix_live_view.js)),
cdn_min: esbuild.(~w(--format=iife --target=es2016 --global-name=LiveView --minify --outfile=../priv/static/phoenix_live_view.min.js))
module:
esbuild.(~w(--format=esm --sourcemap --outfile=../priv/static/phoenix_live_view.esm.js)),
main:
esbuild.(~w(--format=cjs --sourcemap --outfile=../priv/static/phoenix_live_view.cjs.js)),
cdn:
esbuild.(
~w(--format=iife --target=es2016 --global-name=LiveView --outfile=../priv/static/phoenix_live_view.js)
),
cdn_min:
esbuild.(
~w(--format=iife --target=es2016 --global-name=LiveView --minify --outfile=../priv/static/phoenix_live_view.min.js)
)
end
42 changes: 28 additions & 14 deletions lib/phoenix_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,9 @@ defmodule Phoenix.Component do
assigns = %{entries: entries, changed: changed, argument: argument}

~H"""
<%= for entry <- @entries do %><%= call_inner_block!(entry, @changed, @argument) %><% end %>
<%= for entry <- @entries do %>
<%= call_inner_block!(entry, @changed, @argument) %>
<% end %>
"""
end

Expand Down Expand Up @@ -1993,7 +1995,9 @@ defmodule Phoenix.Component do

def live_title(assigns) do
~H"""
<title data-prefix={@prefix} data-suffix={@suffix}><%= @prefix %><%= render_slot(@inner_block) %><%= @suffix %></title>
<title data-prefix={@prefix} data-suffix={@suffix}>
<%= @prefix %><%= render_slot(@inner_block) %><%= @suffix %>
</title>
"""
end

Expand Down Expand Up @@ -2256,10 +2260,10 @@ defmodule Phoenix.Component do
~H"""
<form {@attrs}>
<%= if @hidden_method && @hidden_method not in ~w(get post) do %>
<input name="_method" type="hidden" hidden value={@hidden_method}>
<input name="_method" type="hidden" hidden value={@hidden_method} />
<% end %>
<%= if @csrf_token do %>
<input name="_csrf_token" type="hidden" hidden value={@csrf_token}>
<input name="_csrf_token" type="hidden" hidden value={@csrf_token} />
<% end %>
<%= render_slot(@inner_block, @form) %>
</form>
Expand Down Expand Up @@ -2672,7 +2676,9 @@ defmodule Phoenix.Component do
data-phx-link="redirect"
data-phx-link-state={if @replace, do: "replace", else: "push"}
{@rest}
><%= render_slot(@inner_block) %></a>
>
<%= render_slot(@inner_block) %>
</a>
"""
end

Expand All @@ -2683,7 +2689,9 @@ defmodule Phoenix.Component do
data-phx-link="patch"
data-phx-link-state={if @replace, do: "replace", else: "push"}
{@rest}
><%= render_slot(@inner_block) %></a>
>
<%= render_slot(@inner_block) %>
</a>
"""
end

Expand All @@ -2698,7 +2706,9 @@ defmodule Phoenix.Component do
data-csrf={if @method != "get", do: csrf_token(@csrf_token, @href)}
data-to={if @method != "get", do: @href}
{@rest}
><%= render_slot(@inner_block) %></a>
>
<%= render_slot(@inner_block) %>
</a>
"""
end

Expand Down Expand Up @@ -2807,7 +2817,8 @@ defmodule Phoenix.Component do

if assigns.inner_block != [] do
~H"""
<%= {:safe, [?<, @tag]} %><%= @escaped_attrs %><%= {:safe, [?>]} %><%= render_slot(@inner_block) %><%= {:safe, [?<, ?/, @tag, ?>]} %>
<%= {:safe, [?<, @tag]} %><%= @escaped_attrs %><%= {:safe, [?>]} %><%= render_slot(@inner_block) %><%= {:safe,
[?<, ?/, @tag, ?>]} %>
"""
else
~H"""
Expand Down Expand Up @@ -2877,7 +2888,9 @@ defmodule Phoenix.Component do
data-phx-upload-ref={@upload.ref}
data-phx-active-refs={join_refs(for(entry <- @upload.entries, do: entry.ref))}
data-phx-done-refs={join_refs(for(entry <- @upload.entries, entry.done?, do: entry.ref))}
data-phx-preflighted-refs={join_refs(for(entry <- @upload.entries, entry.preflighted?, do: entry.ref))}
data-phx-preflighted-refs={
join_refs(for(entry <- @upload.entries, entry.preflighted?, do: entry.ref))
}
data-phx-auto-upload={@upload.auto_upload?}
{if @upload.max_entries > 1, do: Map.put(@rest, :multiple, true), else: @rest}
/>
Expand Down Expand Up @@ -2934,7 +2947,8 @@ defmodule Phoenix.Component do
data-phx-entry-ref={@entry.ref}
data-phx-hook="Phoenix.LiveImgPreview"
data-phx-update="ignore"
{@rest} />
{@rest}
/>
"""
end

Expand Down Expand Up @@ -2967,13 +2981,13 @@ defmodule Phoenix.Component do

def intersperse(assigns) do
~H"""
<%= for item <- Enum.intersperse(@enum, :separator) do %><%=
if item == :separator do
<%= for item <- Enum.intersperse(@enum, :separator) do %>
<%= if item == :separator do
render_slot(@separator)
else
render_slot(@inner_block, item)
end
%><% end %>
end %>
<% end %>
"""
end

Expand Down
10 changes: 7 additions & 3 deletions lib/phoenix_component/declarative.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,9 @@ defmodule Phoenix.Component.Declarative do

undefined_slots =
Enum.reduce(slots_defs, slots, fn slot_def, slots ->
%{name: slot_name, required: required, attrs: attrs, validate_attrs: validate_attrs} = slot_def
%{name: slot_name, required: required, attrs: attrs, validate_attrs: validate_attrs} =
slot_def

{slot_values, slots} = Map.pop(slots, slot_name)

case slot_values do
Expand Down Expand Up @@ -1193,9 +1195,11 @@ defmodule Phoenix.Component.Declarative do
# undefined slot attr
%{} ->
cond do
attr_name == :inner_block -> :ok
attr_name == :inner_block ->
:ok

attrs == [] and not validate_attrs -> :ok
attrs == [] and not validate_attrs ->
:ok

true ->
message =
Expand Down
18 changes: 10 additions & 8 deletions lib/phoenix_live_view/async.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ defmodule Phoenix.LiveView.Async do
if Phoenix.LiveView.connected?(socket) do
lv_pid = self()
cid = cid(socket)
{:ok, pid} = if supervisor = Keyword.get(opts, :supervisor) do
Task.Supervisor.start_child(supervisor, fn ->
Process.link(lv_pid)
do_async(lv_pid, cid, key, func, kind)
end)
else
Task.start_link(fn -> do_async(lv_pid, cid, key, func, kind) end)
end

{:ok, pid} =
if supervisor = Keyword.get(opts, :supervisor) do
Task.Supervisor.start_child(supervisor, fn ->
Process.link(lv_pid)
do_async(lv_pid, cid, key, func, kind)
end)
else
Task.start_link(fn -> do_async(lv_pid, cid, key, func, kind) end)
end

ref =
:erlang.monitor(:process, pid, alias: :reply_demonitor, tag: {__MODULE__, key, cid, kind})
Expand Down
1 change: 0 additions & 1 deletion lib/phoenix_live_view/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ defmodule Phoenix.LiveView.Channel do
new_socket
end


{new_socket, {:ok, {msg.ref, %{}}, state}}

other ->
Expand Down
17 changes: 8 additions & 9 deletions lib/phoenix_live_view/engine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,14 @@ defmodule Phoenix.LiveView.Rendered do

@type t :: %__MODULE__{
static: [String.t()],
dynamic:
(boolean() ->
[
nil
| iodata()
| Phoenix.LiveView.Rendered.t()
| Phoenix.LiveView.Comprehension.t()
| Phoenix.LiveView.Component.t()
]),
dynamic: (boolean() ->
[
nil
| iodata()
| Phoenix.LiveView.Rendered.t()
| Phoenix.LiveView.Comprehension.t()
| Phoenix.LiveView.Component.t()
]),
fingerprint: integer(),
root: nil | true | false,
caller:
Expand Down
4 changes: 3 additions & 1 deletion lib/phoenix_live_view/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ defmodule Phoenix.LiveView.Helpers do
assigns = %{title: title, prefix: opts[:prefix], suffix: opts[:suffix]}

~H"""
<Phoenix.Component.live_title prefix={@prefix} suffix={@suffix}><%= @title %></Phoenix.Component.live_title>
<Phoenix.Component.live_title prefix={@prefix} suffix={@suffix}>
<%= @title %>
</Phoenix.Component.live_title>
"""
end

Expand Down
Loading

0 comments on commit fc7272a

Please sign in to comment.