aurelia / aurelia/templating-resources

Two views loading the same CSS resources results in no style being injected

Open
#239 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
55
Forks
55
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a bug report**
- **Library Version:**
1.0.rc

**Please tell us about your environment:**
- **Operating System:**
Windows 10
- **Node Version:**
6.3.0
- **NPM Version:**
3.10.3
- **JSPM OR Webpack AND Version**
webpack 2.1.0-beta.17
- **Browser:**
all
- **Language:**
TypeScript 2.0

**Current behavior:**

When two views request the same resource while loading the app, then the second view seems to assume that the resource has finished loading, and tries to add it (null) to DOM, and sets `_alreadyGloballyInjected` to `true`. Resulting in nothing added. (when the first request finishes loading, it first checks `_alreadyGloballyInjected`, which is true, so it just bails)

finder.html:

```

```

finder-results.html

```

```

**Expected/desired behavior:**

I haven't been able to reproduce it yet in a less complex app, probably because the resources load instantly..
- **What is the expected behavior?**

The second view should wait for the resource to finish loading before trying to process it. Or it shouldn't try to process it at all, because the first view already is doing that.

My workaround:

css-resource.js:

```
function beforeCompile(content, resources, instruction) {
if (this.css === null) return;
```

Contributor guide

Open the contributing guide

Research direction

Start with css-resource.js and trace how concurrent requests from finder.html and finder-results.html handle the shared ./finder.css resource. Verify the second request waits for the first or avoids duplicate processing, and confirm that the stylesheet is injected once rather than being marked complete with a null value.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.