Skip to content

Commit cb146ad

Browse files
committed
merge main (successfully, i think - things changed a bit)
2 parents 54fe12a + 30562b8 commit cb146ad

File tree

26 files changed

+744
-413
lines changed

26 files changed

+744
-413
lines changed

.changeset/real-cameras-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: always use `setAttribute` when setting `style`

.changeset/strange-planes-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: make `style:` directive and CSS handling more robust

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212

1313
jobs:
1414
Tests:
15+
permissions: {}
1516
runs-on: ${{ matrix.os }}
1617
timeout-minutes: 15
1718
strategy:
@@ -41,6 +42,7 @@ jobs:
4142
env:
4243
CI: true
4344
Lint:
45+
permissions: {}
4446
runs-on: ubuntu-latest
4547
timeout-minutes: 5
4648
steps:
@@ -61,6 +63,7 @@ jobs:
6163
if: (${{ success() }} || ${{ failure() }}) # ensures this step runs even if previous steps fail
6264
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally with `cd packages/svelte && pnpm generate:types` and commit the changes after you have reviewed them"; git diff; exit 1); }
6365
Benchmarks:
66+
permissions: {}
6467
runs-on: ubuntu-latest
6568
timeout-minutes: 15
6669
steps:

.github/workflows/ecosystem-ci-trigger.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
if: github.repository == 'sveltejs/svelte' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/ecosystem-ci run')
1111
steps:
12+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1213
- uses: actions/github-script@v6
1314
with:
1415
script: |

.github/workflows/pkg.pr.new-comment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
name: 'Update comment'
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1415
- name: Download artifact
1516
uses: actions/download-artifact@v4
1617
with:

.github/workflows/pkg.pr.new.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on: [push, pull_request]
33

44
jobs:
55
build:
6+
permissions: {}
7+
68
runs-on: ubuntu-latest
79

810
steps:

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
name: Release
1818
runs-on: ubuntu-latest
1919
steps:
20+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2021
- name: Checkout Repo
2122
uses: actions/checkout@v4
2223
with:

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,17 +769,24 @@ export function analyze_component(root, source, options) {
769769
}
770770

771771
let has_class = false;
772+
let has_style = false;
772773
let has_spread = false;
773774
let has_class_directive = false;
775+
let has_style_directive = false;
774776

775777
for (const attribute of node.attributes) {
776778
// The spread method appends the hash to the end of the class attribute on its own
777779
if (attribute.type === 'SpreadAttribute') {
778780
has_spread = true;
779781
break;
782+
} else if (attribute.type === 'Attribute') {
783+
has_class ||= attribute.name.toLowerCase() === 'class';
784+
has_style ||= attribute.name.toLowerCase() === 'style';
785+
} else if (attribute.type === 'ClassDirective') {
786+
has_class_directive = true;
787+
} else if (attribute.type === 'StyleDirective') {
788+
has_style_directive = true;
780789
}
781-
has_class_directive ||= attribute.type === 'ClassDirective';
782-
has_class ||= attribute.type === 'Attribute' && attribute.name.toLowerCase() === 'class';
783790
}
784791

785792
// We need an empty class to generate the set_class() or class="" correctly
@@ -796,6 +803,21 @@ export function analyze_component(root, source, options) {
796803
])
797804
);
798805
}
806+
807+
// We need an empty style to generate the set_style() correctly
808+
if (!has_spread && !has_style && has_style_directive) {
809+
node.attributes.push(
810+
create_attribute('style', -1, -1, [
811+
{
812+
type: 'Text',
813+
data: '',
814+
raw: '',
815+
start: -1,
816+
end: -1
817+
}
818+
])
819+
);
820+
}
799821
}
800822

801823
// TODO

0 commit comments

Comments
 (0)