Skip to content

Instantly share code, notes, and snippets.

@ForbesLindesay
Last active December 15, 2015 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ForbesLindesay/5280494 to your computer and use it in GitHub Desktop.
Save ForbesLindesay/5280494 to your computer and use it in GitHub Desktop.
@import "./fixture.css" screen;
@import "./fixture.css" print;
/* This a fixture to be imported */
.foo {
bar: 'baz';
}

You're challenge, should you choose to accept it, is to inline the following @import statements in CSS. What should the result be. "SyntaxError" is a perfectly acceptable answer. If anyone knows what the current spec does, I'd be interested to know, but I'm equally keen to find out what people think the spec should do.

Please place the results of inlining @import statements in each file (except fixture.css) in the comments. Your help is appreciated, and if I meet you in a bar some time, I owe you a pint.

.bar {
bing: 'bong';
}
@import "./fixture.css";
@media screen {
.bar {
bing: 'bong';
}
@import "./fixture.css";
}
@media screen {
@import "./fixture.css";
}
.bar {
bing: 'bong';
}
@media screen {
@import "./fixture.css";
}
@import "./fixture.css";
@import "./fixture.css";
.bar {
bing: 'bong';
}
@import "./fixture.css";
.bar {
bing: 'bong';
}
@ForbesLindesay
Copy link
Author

My best guess:

err-what.css:

@media screen {
  /* This a fixture to be imported */

  .foo {
    bar: 'baz';
  }
}
@media print {
  /* This a fixture to be imported */

  .foo {
    bar: 'baz';
  }
}

Late to the party:

Syntax error, only allow @import statements at the start of the file or in an @media block

mass media:

Syntax error, @import statements must be at the top of any @media block

Overhyped:

I'm really not sure about this one???

Repeated:

Only import the same file once, ignore multiple imports

/* This a fixture to be imported */

.foo {
  bar: 'baz';
}
.bar {
  bing: 'bong';
}

Simple:

/* This a fixture to be imported */

.foo {
  bar: 'baz';
}
.bar {
  bing: 'bong';
}

@ForbesLindesay
Copy link
Author

I've made some progress. According to MDN, it's a syntax error unless they're at the top of the document (which keeps things nice and simple). @visionmedia has suggested just doing a simple include might be best (i.e. replace @import 'foo'; with the contents of 'foo'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment