emmet-mode icon indicating copy to clipboard operation
emmet-mode copied to clipboard

Parts of expression descendant from paren expression are silently dropped.

Open pobocks opened this issue 10 years ago • 4 comments

When expanding an emmet expression, anything descendant of a parenthesized expression is discarded silently.

For example, this:

(div)>p|

expands to:

<div></div>

but should expand to:

<div>
  <p></p>
</div>

pobocks avatar Aug 25 '14 15:08 pobocks

Why should? How, for example, you will expand the following abbr: (div+p*2)>span? I don't see a logical way of expanding this. Emmet Core treats (a)>b as a+b, check this out.

flyingleafe avatar Aug 27 '14 13:08 flyingleafe

I had a whole bunch of examples, but I realized as I was writing them out that I do, in fact, want different behaviors in different circumstances. :frowning:

Regardless, silently throwing away user input seems wrong - if all else fails, we should do what Emmet Core does, or preserve user input and append to the expansion as a whole, or throw an error and bail out.

pobocks avatar Aug 27 '14 18:08 pobocks

The place where this really hits me is with the HTML snippets - html:5 has a defined point where > should leave things, and it would be really nice to be able to say, for instance:

html:5>(#wrap>#content)+#footer|

and get:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <title>Document</title>
  </head>
  <body>
    <div id="wrap">
      <content>|</content>
    </div>
    <div id="footer"></div>
  </body>
</html>

but I recognize that that may not be feasible or worth the effort.

pobocks avatar Aug 27 '14 18:08 pobocks

For what it's worth, Emmet appears to have defined behavior for this, and it's to treat a > following a parenthetical as a sibling selector. Not sure that's behavior worth replicating, though - I think an error or warning of some kind would be The Right Thing™

Thoughts? I'm happy to do the code for either treating as sibling or throwing an error/warning, but I'm not sure which I should do.

pobocks avatar Sep 25 '15 14:09 pobocks