-
Notifications
You must be signed in to change notification settings - Fork 667
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
Improve passing text to slots #274
Conversation
src/lib/add-slots.js
Outdated
if (typeof slotValue === 'string') { | ||
if (!compileToFunctions) { | ||
throwError('vueTemplateCompiler is undefined, you must pass components explicitly if vue-template-compiler is undefined') | ||
} | ||
if (slotValue.trim()[0] === '<') { | ||
const domParser = new window.DOMParser() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOMParser isn't supported in phantomJs, so we need an alternative that will work in phantom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing.
Is there a choice not to support PhantomJS ?
IMHO, I think it is better to use Puppeteer.
It is better to introduce Puppeteer at document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of users still use phantom. We could throw an error, or a warning that phantom doesn't support markup in slots, and handle it gracefully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reply.
I will look for other ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the error message to—option.slots does not support strings PhantomJS. Please use Puppeteer, or pass a component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry.
I did not notice your comment.
I fixed the error message.
I changed this. |
}) | ||
|
||
afterEach(() => { | ||
/* eslint-disable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm mistakenm you can just add // eslint-disable-line to the line, instead of 2 comments. Even better, you can add //eslint-disable-line name-of-rule
to only disable eslint for the rule which is failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out.
I fixed it.
I am sorry. |
I am sorry. <template>
<div class="container" @click='change'>
<header>
<slot name="header"></slot>
</header>
<main>
<slot></slot>
</main>
<footer>
<slot name="footer"></slot>
</footer>
</div>
</template>
<script>
export default {
name: 'component-with-slots',
data () {
return {
'foo': 'bar'
}
},
methods: {
change () {
this.foo = 'baz'
}
}
}
</script> const wrapper5 = mount(ComponentWithSlots, { slots: { default: '1{{ foo }}2' }})
wrapper5.find('.container').trigger('click')
expect(wrapper5.find('main').html()).to.equal('<main>1baz2</main>')
// => <main>undefined</main> |
I think it is resolved. |
src/lib/add-slots.js
Outdated
if (typeof slotValue === 'string') { | ||
if (!compileToFunctions) { | ||
throwError('vueTemplateCompiler is undefined, you must pass components explicitly if vue-template-compiler is undefined') | ||
} | ||
if (slotValue.trim()[0] === '<') { | ||
if (window.navigator.userAgent.match(/PhantomJS/i)) { | ||
throwError('option.slots does not support strings PhantomJS. Please use Puppeteer, or pass a component') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
option.slots does not support strings PhantomJS. Please use Puppeteer, or pass a component
to
option.slots does not support strings in PhantomJS. Please use Puppeteer, or pass a component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it.
This is related to #244 .
The text works below.