Repository: svelte
Issue: Using `dir` attribute with surrounding content triggers "Cannot read properties of null (reading 'type')"
Labels: bug

### Describe the bug

Adding `dir="auto"` to elements in a Svelte component causes compiler errors if there are multiple such elements or any surrounding content. The error does not happen if `dir="auto"` is used on a single isolated element.

When adding a `dir="auto"` attribute to an HTML element in a Svelte component, everything seems fine if that element is the only element in the component. However, once there is any additional content before or after it—or if there are multiple elements each with `dir="auto"`—the compiler throws this error:

```
Error compiling component
Cannot read properties of null (reading 'type')
```

### Examples of the issue in the Svelte Playground

- This code **does NOT** error:

  ```svelte
  <h1 dir="auto">Hello</h1>
  ```
- This code **does** error:

  ```svelte
  <h1 dir="auto">Hello</h1>
  <h1 dir="auto">Hello</h1>
  ```
- Also errors:
 
  ```svelte
  Hello
  <h1 dir="auto">Hello</h1>
  ```
  And:

  ```svelte
  <h1 dir="auto">Hello</h1>
  Hello
  ```

I discovered this because in MDsveX-based project, whenever I set `node.properties.dir = "auto"` on certain nodes, the same compiler error occurs, even though removing `dir="auto"` fixes the issue. Here's the [rehype-callouts plugin issue discussion](https://github.com/lin-stephanie/rehype-callouts/issues/18) where I initially encountered the error.

### Reproduction

- [https://stackblitz.com/~/github.com/lin-stephanie/svelte-issue-15126](https://stackblitz.com/~/github.com/lin-stephanie/svelte-issue-15126?file=src/routes/App.svelte)
- https://github.com/lin-stephanie/svelte-issue-15126

### Logs

```shell
[vite] Internal server error: Cannot read properties of null (reading 'type')
  Plugin: vite-plugin-svelte
  File: /home/lin-stephanie/svelte-issue-15126/src/routes/App.svelte
      at MemberExpression (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:1204:42)
      at handle (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:74:2)
      at AssignmentExpression (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:891:3)
      at handle (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:74:2)
      at ArrowFunctionExpression (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:886:4)
      at handle (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:74:2)
      at CallExpression|NewExpression (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:759:4)
      at handle (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:74:2)
      at ExpressionStatement (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:1069:3)
      at handle (file:///home/lin-stephanie/svelte-issue-15126/node_modules/.pnpm/esrap@1.4.3/node_modules/esrap/src/handlers.js:74:2)
```

### System Info

```shell
System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    svelte: ^5.0.0 => 5.19.3
```

### Severity

annoyance