Comments (3)
I don't understand how can <my-component />
be rendered correctly as self-closing tags for custom elements don't work with AngularJS. Here is a quote from Igor Minar:
self-closing or void elements as the html spec defines them are very special to the browser parser. you can't make your own, so for your custom elements you have to stick to non-void elements ().
this can't be changed in angular. closing.
angular/angular.js#1953 (comment)
I think it should work with $compile('<my-component></my-component>')($rootScope).html()
from ngvue.
Hi @nicolaspayot, Thanks for looking into this.
I guess it must be the browser that's permitting the use of the self closing tag (Chrome 72.0.3626).
I think it should work with
$compile('<my-component></my-component>')($rootScope).html()
I've written some karma tests to show that it doesn't work without having a wrapper div regardless of self closing tags or not. This is different to the angular behavior which doesn't require the outer div
angular
.module('test', ['ngVue'])
.component('myAng', {
template: "<span>Hello From Angular</span>"
})
.value('myVue', {
template: "<span>Hello From Vue</span>"
})
.directive('myVue', function (createVueComponent) {
return createVueComponent('myVue')
})
describe('ngVue compilation', () => {
var $compile;
var $rootScope;
beforeEach(() => {
angular.mock.module('test');
angular.mock.inject((_$compile_, _$rootScope_) => {
$compile = _$compile_
$rootScope = _$rootScope_
})
})
it('Renders angular components with no wrapper', () => {
var contentShort = $compile('<my-ang/>')($rootScope.$new());
expect(contentShort.text()).toBe("Hello From Angular")
var contentLong = $compile('<my-ang></my-ang>')($rootScope.$new());
expect(contentLong.html()).toBe(contentShort.html())
})
it('Renders vue components with wrapper', () => {
var contentShort = $compile('<div><my-vue/></div>')($rootScope.$new());
expect(contentShort.text()).toBe("Hello From Vue")
var contentLong = $compile('<div><my-vue></my-vue></div>')($rootScope.$new());
expect(contentLong.html()).toBe(contentShort.html())
})
//THIS ONE FAILS!
it('Renders vue components with no wrapper', () => {
var contentLong = $compile('<my-vue></my-vue>')($rootScope.$new());
expect(contentLong.text()).toBe("Hello From Vue")
})
})
This could cause an issue for anyone who is trying to do a direct conversion from their angular components into vue (which is where I had the issue) and this request should save them a lot of trouble.
from ngvue.
Fixed with #85
from ngvue.
Related Issues (20)
- Support for composition api? HOT 2
- .sync modifier HOT 2
- Vue3 support HOT 6
- Support multiple children in <slot>
- How to listen to broadcasted event from angular components into Vue component? HOT 4
- Vue component not rendering on IE HOT 1
- Vue-apollo provider doesn't work
- How to use Vue.js provide/inject with ngVue?
- Quirk Mode doesn't work.
- Specify `module` to `build/index.esm.js` in `package.json` to support ESM import HOT 2
- Incorrect main/module/exports in `package.json` in v2.1.1 HOT 2
- Mount Vue in ShadowDOM HOT 1
- Plugins do not work with Webpack 5 HOT 4
- Time to remove that deprecation message? HOT 4
- Update to the Vuex store does not trigger update in the components in debug mode. HOT 2
- Uncaught TypeError: e.warn is not a function
- `process` is not defined in all build environments
- Usefulness of $compile for slot HOT 1
- Deprecation warning for camelCase event names cannot be suppressed HOT 5
- v-directive not updating value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngvue.