File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ <h1>Basic Example</h1>
150150 secondary: 'papayawhip',
151151 tertiary: 'lavenderblush'
152152 }">
153+ <!--
153154 <wrapper>
154155 <custom-title :visible="true" :animate="animated1"> {{text1}} </custom-title>
155156 <styled-input v-model="text1" />
@@ -160,6 +161,7 @@ <h1>Basic Example</h1>
160161 <styled-input v-model="text2" />
161162 <super-btn visible @click="animated2 = !animated2"> An extension of Styled Button </super-btn>
162163 </w-2>
164+ -->
163165 <w-3
164166 bg="#c6f7e6"
165167 >
Original file line number Diff line number Diff line change 11import css from '../constructors/css'
22import normalizeProps from '../utils/normalizeProps'
3+ import isVueComponent from '../utils/isVueComponent'
34
45export default ( ComponentStyle ) => {
56 const createStyledComponent = ( target , rules , props ) => {
@@ -39,7 +40,19 @@ export default (ComponentStyle) => {
3940 }
4041
4142 return createElement (
42- this . $props . as || target ,
43+ /**
44+ * The reason for this check is to test whether the "target" is a Vue / Styled component.
45+ * If the target is a styled component, we render that styled component to preserve the
46+ * styles inherited from the "target" in the new component to be rendered.
47+ *
48+ * The "target" will inherently possess the "as" polymorphic prop. This allows the
49+ * consumer component to render the tag passed inside of it's "as" element it's
50+ * rendering recursively.
51+ *
52+ * Otherwise if the "target" is not a styled component we render the "as" prop element.
53+ * If the "as" prop is not provided, we use the default element.
54+ */
55+ isVueComponent ( target ) ? target : this . $props . as || target ,
4356 {
4457 class : [ this . generatedClassName ] ,
4558 props : this . $props ,
You can’t perform that action at this time.
0 commit comments