LoginSignup
5
5

More than 5 years have passed since last update.

Sass 3.3.0.rc.1で実装された#{&}-hogeの記法は廃止になった。

Last updated at Posted at 2014-03-04

Sass 3.3の新機能の一つとして予定されていた、#{}&を組み合わせることでBEM等の記法を簡潔に表現できる機能ですが、3.3.0.rc.1の時点で一旦実装されたものの、仕様上の問題があり廃止になっていたようです。

https://github.com/nex3/sass/commit/cbd07dac56028e2216972e1c009d7bf24027b588
https://github.com/nex3/sass/commit/3f1498a55d89f50c343368dbd012313bf9c5ae16
https://gist.github.com/nex3/8050187

3.3.0.rc.6の時点では、代わりに単純に&をprefixとして使うことで、親の名前を展開できるようになりました。ドキュメントの例を借りれば、従来は以下のような記法だったのが、

#main {
    #{&}-sidebar { border: 1px solid; } // #main-sidebarとして出力される
}

以下のような記法に変わったということです。

#main {
    &-sidebar { border: 1px solid; } // 効果は同様
}

なお、現状では&をprefixとしてのみ使えるようです。
alphaやrcと銘打たれたものに手を出すと、こういう思わぬ仕様変更につまづきかねないといういい例ですね。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5