Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement namespaced components #2743

Merged
merged 5 commits into from May 12, 2019
Merged

implement namespaced components #2743

merged 5 commits into from May 12, 2019

Conversation

Rich-Harris
Copy link
Member

This allows components to be member expressions — so instead of this...

<script>
  import {
    Scene,
    PerspectiveCamera,
    OrbitControls,
    AmbientLight,
    DirectionalLight,
    Plane,
    Box
  } from '@sveltejs/gl';
</script>

<Scene>
  <OrbitControls let:location let:target>
    <PerspectiveCamera {location} {target}/>
  </OrbitControls>

  <DirectionalLight direction={[-1,-1,-1]} intensity={0.8}/>

  <Plane
    color={0xffffff}
    location={[0,-0.01,0]}
    rotation={[-90,0,0]}
    scale={10}
  />

  <Box location={[0,0.5,0]}/>
</Scene>

...you can do this:

<script>
  import * as GL from '@sveltejs/gl';
</script>

<GL.Scene>
  <GL.OrbitControls let:location let:target>
    <GL.PerspectiveCamera {location} {target}/>
  </GL.OrbitControls>

  <GL.DirectionalLight direction={[-1,-1,-1]} intensity={0.8}/>

  <GL.Plane
    color={0xffffff}
    location={[0,-0.01,0]}
    rotation={[-90,0,0]}
    scale={10}
  />

  <GL.Box location={[0,0.5,0]}/>
</GL.Scene>

@Conduitry
Copy link
Member

Aside from the test failures, this also does not update the vars stuff or the missing-declaration warnings appropriately.

@Rich-Harris
Copy link
Member Author

Well caught, thanks. Fixed

@@ -23,8 +23,9 @@ export default class InlineComponent extends Node {
super(component, parent, scope, info);

if (info.name !== 'svelte:component' && info.name !== 'svelte:self') {
component.warn_if_undefined(info, scope);
component.add_reference(info.name);
const name = info.name.split('.')[0]; // accommodate namespaces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it not seem safe to just roll this logic into warn_if_undefined itself instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I guess you need to add_reference here with it anyway. It might be nice though if warn_if_undefined didn't require an extra name arg as well as the info arg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's silly to let this hold up the PR actually, gonna go ahead an approve

@Rich-Harris Rich-Harris merged commit 68d7dca into master May 12, 2019
@Rich-Harris Rich-Harris deleted the namespaced-components branch May 12, 2019 20:15
@6122617139

This comment has been minimized.

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

Successfully merging this pull request may close these issues.

None yet

3 participants