Skip to content

Commit

Permalink
fix: add back custom tagname
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya committed Oct 4, 2020
1 parent 385b451 commit 3eb6d62
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 34 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Not sure what Shadow DOM is? Check out this [MDN article](https://developer.mozi
Compatibility
------------------------------------------------------------------------------

* Ember.js v2.18 or above
* Ember.js v3.7.2 or above ([See why][see-why])
* Ember CLI v2.13 or above


Expand Down Expand Up @@ -63,16 +63,17 @@ API

- `@mode` (string) - The mode of the Shadow Root, defaults to `'open'`. Can be `'open'` or `'closed'`.
Note that `'closed'` mode prevents you from querying into the DOM of your components in tests.
<!-- - `@tagName` (string) - This defaults to `'div'`, but can be any valid element tag name used in HTML.
Setting this argument changes the top level element that the shadow root is attached to. -->
- `@tagName` (string) - This defaults to `'div'`, but can be any valid element tag name used in HTML.
Setting this argument changes the top level element that the shadow root is attached to.

Testing
-------

Components with a open shadowroot can be tested using qunit-dom like so:

```js
assert.dom('.block', find('#internal').shadowRoot).hasText('template block text');
let root = find('#internal').shadowRoot;
assert.dom('.block', root).hasText('template block text');
```

Where the template looks like:
Expand Down Expand Up @@ -102,3 +103,4 @@ This project is licensed under the [MIT License](LICENSE.md).

[npm-badge]: https://badge.fury.io/js/ember-shadow-dom.svg
[npm-badge-url]: http://badge.fury.io/js/ember-shadow-dom
[see-why]: https://github.com/tildeio/ember-element-helper/issues/6#issuecomment-519349886]]
15 changes: 7 additions & 8 deletions app/templates/components/shadow-dom.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{{!-- {{#let (element this.tagName) as |Tag|}}
{{#let (element this.tagName) as |Tag|}}
<Tag
{{did-insert this.setupRoot}}
...attributes
/>
{{/let}} --}}
<div {{did-insert this.setupRoot}} ...attributes>
{{#unless this.shadow}}
{{yield}}
{{/unless}}
</div>
>
{{#unless this.shadow}}
{{yield}}
{{/unless}}
</Tag>
{{/let}}

{{#if this.shadow}}
{{#-in-element this.shadow}}
Expand Down
16 changes: 2 additions & 14 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@ module.exports = function() {
return {
scenarios: [
{
name: 'ember-lts-2.18',
env: {
EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true })
},
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1',
'ember-source': '~2.18.0'
}
}
},
{
name: 'ember-lts-3.4',
name: 'ember-lts-3.7.2',
npm: {
devDependencies: {
'ember-source': '~3.4.0'
'ember-source': '~3.7.2'
}
}
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"release": "standard-version"
},
"dependencies": {
"ember-element-helper": "^0.1.1",
"@ember/render-modifiers": "^1.0.0",
"@glimmer/component": "^0.14.0-alpha.7",
"ember-cli-babel": "^7.7.0",
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/components/shadow-dom/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ module('Integration | Component | shadow-dom', function(hooks) {
assert.dom('.block', find('#internal').shadowRoot).doesNotExist();
});

// test('it can have a different tag name', async function(assert) {
// await render(hbs`
// <ShadowDom @tagName='span'>
// <div class='block'>template block text</div>
// </ShadowDom>
// `);
test('it can have a different tag name', async function(assert) {
await render(hbs`
<ShadowDom @tagName='span'>
<div class='block'>template block text</div>
</ShadowDom>
`);

// assert.dom('.block', find('span').shadowRoot).hasText('template block text');
// });
assert.dom('.block', find('span').shadowRoot).hasText('template block text');
});
});
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4544,6 +4544,13 @@ ember-compatibility-helpers@^1.1.1, ember-compatibility-helpers@^1.1.2, ember-co
semver "^5.6.0"
silent-error "^1.1.1"

ember-element-helper@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ember-element-helper/-/ember-element-helper-0.1.1.tgz#ffd2a0566b22a13c0e7780ae96443f4ffda2e63d"
integrity sha512-MfES7MbZ5UcHTo1lutJCcz6hI+/CadurWcOR3kOQl0jKcBKdAWyYIJXK4u0FDXzlgKczX9vL3R2eJUtnGe144w==
dependencies:
ember-cli-babel "^6.16.0"

ember-export-application-global@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.0.tgz#8d6d7619ac8a1a3f8c43003549eb21ebed685bd2"
Expand Down

0 comments on commit 3eb6d62

Please sign in to comment.