From 584e89da4ab17e1ebdae0ae10be77ef9d230c7a0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 12 Jan 2019 01:23:51 -0500 Subject: [PATCH] feat: support slot-props and its shorthand See https://github.com/vuejs/vue/issues/9306 for more details. --- src/compiler/parser/index.js | 118 ++++++++++++------ .../component/component-scoped-slot.spec.js | 101 +++++++++++++++ 2 files changed, 179 insertions(+), 40 deletions(-) diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index 65e334d64..49a171e10 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -45,6 +45,7 @@ let postTransforms let platformIsPreTag let platformMustUseProp let platformGetTagNamespace +let maybeComponent export function createASTElement ( tag: string, @@ -74,6 +75,8 @@ export function parse ( platformIsPreTag = options.isPreTag || no platformMustUseProp = options.mustUseProp || no platformGetTagNamespace = options.getTagNamespace || no + const isReservedTag = options.isReservedTag || no + maybeComponent = (el: ASTElement) => !!el.component || !isReservedTag(el.tag) transforms = pluckModuleFunction(options.modules, 'transformNode') preTransforms = pluckModuleFunction(options.modules, 'preTransformNode') @@ -390,7 +393,8 @@ export function processElement ( ) processRef(element) - processSlot(element) + processSlotContent(element) + processSlotOutlet(element) processComponent(element) for (let i = 0; i < transforms.length; i++) { element = transforms[i](element, options) || element @@ -542,7 +546,79 @@ function processOnce (el) { } } -function processSlot (el) { +// handle content being passed to a component as slot, +// e.g.