Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

System.delete("file.css") should remove link from head #81

Closed
alexisvincent opened this issue Mar 25, 2016 · 6 comments
Closed

System.delete("file.css") should remove link from head #81

alexisvincent opened this issue Mar 25, 2016 · 6 comments

Comments

@alexisvincent
Copy link

System.delete("file.css") should remove link from head. When hot reloading css with capaj/systemjs-hot-reloader.

Currently the delete does nothing. And then the css file is injected. So what ends up happing is actually a minimal overwrite.

a.css

lol {
  background: blue;
  color: green;
}

a2.css

lol {
  background: blue;
}

The expectation is that the color property is no longer being specified. But it is.

@guybedford
Copy link
Member

Try System.delete(System.normalizeSync('file.css')) here. This is because the registry contains only normalized names.

@alexisvincent
Copy link
Author

Tried your solution but doesn't seem to work, unless I'm missing something. It only removes it from the registry, not the dom node.

I've repurposed https://github.com/alexisvincent/system-ja-stack-trace-error to demonstrate this issue.

To reproduce, serve the repo and run

System.delete(System.normalizeSync('app.css!'))

in the console

@guybedford
Copy link
Member

Yes, even if the module is deleted from the registry that does not mean the CSS is unloaded as there is no unload pipeline for modules removed from the registry. It's best to follow the principles of modular CSS so that unloading of CSS is not necessary due to careful scoping.

@alexisvincent
Copy link
Author

What are your thoughts on implementing an unload of css. In my mind it would be what people intuitively expect.

@guybedford
Copy link
Member

It could be done by having the CSS module itself export an "unload" function, which disposes of its own registry entry. But it shouldn't be encouraged.

@alexisvincent
Copy link
Author

For me, it would make sense to add an unload step that loaders can implement if they want to, I'm positive there are other cases where a loader might want to do some initialisation and subsequently some finalisation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants