From 3f31e6e62def821275658fdbaf4ef1626b8701e8 Mon Sep 17 00:00:00 2001 From: lifeart Date: Mon, 8 Oct 2018 13:27:13 +0300 Subject: [PATCH] slashed components rendering and ignore issue fix --- addon/mixins/hot-reload-resolver.js | 11 +++--- .../inline-template/component.js | 9 +++++ .../excluded-slashed-pod/js-only/component.js | 9 +++++ .../mixed-classic/component.js | 6 +++ .../mixed-classic/template.hbs | 2 + .../template-only/template.hbs | 1 + .../excluded-slashed/inline-template.js | 9 +++++ .../components/excluded-slashed/js-only.js | 8 ++++ .../excluded-slashed/mixed-classic.js | 6 +++ .../slashed-pod/inline-template/component.js | 9 +++++ .../slashed-pod/js-only/component.js | 9 +++++ .../slashed-pod/mixed-classic/component.js | 6 +++ .../slashed-pod/mixed-classic/template.hbs | 2 + .../slashed-pod/template-only/template.hbs | 1 + .../app/components/slashed/inline-template.js | 9 +++++ tests/dummy/app/components/slashed/js-only.js | 8 ++++ .../app/components/slashed/mixed-classic.js | 6 +++ tests/dummy/app/resolver.js | 11 +++++- tests/dummy/app/templates/application.hbs | 37 +++++++++++++++++++ .../excluded-slashed/mixed-classic.hbs | 2 + .../excluded-slashed/template-only.hbs | 2 + .../components/slashed/mixed-classic.hbs | 2 + .../components/slashed/template-only.hbs | 2 + 23 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 tests/dummy/app/components/excluded-slashed-pod/inline-template/component.js create mode 100644 tests/dummy/app/components/excluded-slashed-pod/js-only/component.js create mode 100644 tests/dummy/app/components/excluded-slashed-pod/mixed-classic/component.js create mode 100644 tests/dummy/app/components/excluded-slashed-pod/mixed-classic/template.hbs create mode 100644 tests/dummy/app/components/excluded-slashed-pod/template-only/template.hbs create mode 100644 tests/dummy/app/components/excluded-slashed/inline-template.js create mode 100644 tests/dummy/app/components/excluded-slashed/js-only.js create mode 100644 tests/dummy/app/components/excluded-slashed/mixed-classic.js create mode 100644 tests/dummy/app/components/slashed-pod/inline-template/component.js create mode 100644 tests/dummy/app/components/slashed-pod/js-only/component.js create mode 100644 tests/dummy/app/components/slashed-pod/mixed-classic/component.js create mode 100644 tests/dummy/app/components/slashed-pod/mixed-classic/template.hbs create mode 100644 tests/dummy/app/components/slashed-pod/template-only/template.hbs create mode 100644 tests/dummy/app/components/slashed/inline-template.js create mode 100644 tests/dummy/app/components/slashed/js-only.js create mode 100644 tests/dummy/app/components/slashed/mixed-classic.js create mode 100644 tests/dummy/app/templates/components/excluded-slashed/mixed-classic.hbs create mode 100644 tests/dummy/app/templates/components/excluded-slashed/template-only.hbs create mode 100644 tests/dummy/app/templates/components/slashed/mixed-classic.hbs create mode 100644 tests/dummy/app/templates/components/slashed/template-only.hbs diff --git a/addon/mixins/hot-reload-resolver.js b/addon/mixins/hot-reload-resolver.js index 4fce10b..7b2cbf3 100644 --- a/addon/mixins/hot-reload-resolver.js +++ b/addon/mixins/hot-reload-resolver.js @@ -11,7 +11,7 @@ const TEMPLATE_MATCH_REGEX = new RegExp(/-original$/); function removeOriginalFromParsedName (parsedName, pattern) { parsedName.fullName = parsedName.fullName.replace(pattern, ''); parsedName.fullNameWithoutType = parsedName.fullNameWithoutType.replace(pattern, ''); - parsedName.name= parsedName.name.replace(pattern, ''); + parsedName.name = parsedName.name.replace(pattern, ''); } function shouldIgnoreTemplate (parsedName, pattern) { @@ -36,14 +36,15 @@ export default Mixin.create({ resolveOther(parsedName) { captureTemplateOptions(parsedName); const templateMatchRegex = get(this, 'originalTemplateMatchRegex'); + const resolved = this._super(...arguments); + if (parsedName.type === 'template' && shouldIgnoreTemplate(parsedName, templateMatchRegex)) { - return; + return resolved; } - - const resolved = this._super(...arguments); + if (parsedName.type === 'component') { if (this.shouldExcludeComponent(parsedName)) { - return this._super(parsedName); + return resolved; } if (resolved) { return this._resolveComponent(resolved, parsedName); diff --git a/tests/dummy/app/components/excluded-slashed-pod/inline-template/component.js b/tests/dummy/app/components/excluded-slashed-pod/inline-template/component.js new file mode 100644 index 0000000..a82b63c --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed-pod/inline-template/component.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; +import hbs from 'htmlbars-inline-precompile'; + +export default Component.extend({ + layout: hbs` +

Inline slashed pod component rendering test {{myName}}

+ `, + myName: 'excluded-slashed-pod/inline-template' +}); \ No newline at end of file diff --git a/tests/dummy/app/components/excluded-slashed-pod/js-only/component.js b/tests/dummy/app/components/excluded-slashed-pod/js-only/component.js new file mode 100644 index 0000000..42b8be1 --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed-pod/js-only/component.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; + +export default Component.extend({ + tagName: 'div', + classNames: ['excluded-slashed-pod__js-only'], + didRender() { + this.element.innerHTML = ''; + } +}); diff --git a/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/component.js b/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/component.js new file mode 100644 index 0000000..ab273cd --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/component.js @@ -0,0 +1,6 @@ +import Component from '@ember/component'; +import layout from './template'; + +export default Component.extend({ + layout +}); diff --git a/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/template.hbs b/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/template.hbs new file mode 100644 index 0000000..e581558 --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed-pod/mixed-classic/template.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file diff --git a/tests/dummy/app/components/excluded-slashed-pod/template-only/template.hbs b/tests/dummy/app/components/excluded-slashed-pod/template-only/template.hbs new file mode 100644 index 0000000..da5d3a6 --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed-pod/template-only/template.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/dummy/app/components/excluded-slashed/inline-template.js b/tests/dummy/app/components/excluded-slashed/inline-template.js new file mode 100644 index 0000000..7746d01 --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed/inline-template.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; +import hbs from 'htmlbars-inline-precompile'; + +export default Component.extend({ + layout: hbs` +

Inline slashed component rendering test {{myName}}

+ `, + myName: 'excluded-slashed/inline-template' +}); \ No newline at end of file diff --git a/tests/dummy/app/components/excluded-slashed/js-only.js b/tests/dummy/app/components/excluded-slashed/js-only.js new file mode 100644 index 0000000..81f8fef --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed/js-only.js @@ -0,0 +1,8 @@ +import Component from '@ember/component'; +export default Component.extend({ + tagName: 'div', + classNames: ['excluded-slashed__js-only'], + didRender() { + this.element.innerHTML = ''; + } +}); diff --git a/tests/dummy/app/components/excluded-slashed/mixed-classic.js b/tests/dummy/app/components/excluded-slashed/mixed-classic.js new file mode 100644 index 0000000..5ec458f --- /dev/null +++ b/tests/dummy/app/components/excluded-slashed/mixed-classic.js @@ -0,0 +1,6 @@ +import Component from '@ember/component'; +import layout from '../../templates/components/slashed/mixed-classic'; + +export default Component.extend({ + layout +}); diff --git a/tests/dummy/app/components/slashed-pod/inline-template/component.js b/tests/dummy/app/components/slashed-pod/inline-template/component.js new file mode 100644 index 0000000..b8ed4eb --- /dev/null +++ b/tests/dummy/app/components/slashed-pod/inline-template/component.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; +import hbs from 'htmlbars-inline-precompile'; + +export default Component.extend({ + layout: hbs` +

Inline slashed pod component rendering test {{myName}}

+ `, + myName: 'slashed-pod/inline-template' +}); \ No newline at end of file diff --git a/tests/dummy/app/components/slashed-pod/js-only/component.js b/tests/dummy/app/components/slashed-pod/js-only/component.js new file mode 100644 index 0000000..6ff001b --- /dev/null +++ b/tests/dummy/app/components/slashed-pod/js-only/component.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; + +export default Component.extend({ + tagName: 'div', + classNames: ['slashed-pod__js-only'], + didRender() { + this.element.innerHTML = ''; + } +}); diff --git a/tests/dummy/app/components/slashed-pod/mixed-classic/component.js b/tests/dummy/app/components/slashed-pod/mixed-classic/component.js new file mode 100644 index 0000000..ab273cd --- /dev/null +++ b/tests/dummy/app/components/slashed-pod/mixed-classic/component.js @@ -0,0 +1,6 @@ +import Component from '@ember/component'; +import layout from './template'; + +export default Component.extend({ + layout +}); diff --git a/tests/dummy/app/components/slashed-pod/mixed-classic/template.hbs b/tests/dummy/app/components/slashed-pod/mixed-classic/template.hbs new file mode 100644 index 0000000..fa2f24e --- /dev/null +++ b/tests/dummy/app/components/slashed-pod/mixed-classic/template.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file diff --git a/tests/dummy/app/components/slashed-pod/template-only/template.hbs b/tests/dummy/app/components/slashed-pod/template-only/template.hbs new file mode 100644 index 0000000..84c8a8d --- /dev/null +++ b/tests/dummy/app/components/slashed-pod/template-only/template.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/dummy/app/components/slashed/inline-template.js b/tests/dummy/app/components/slashed/inline-template.js new file mode 100644 index 0000000..1cbcf3c --- /dev/null +++ b/tests/dummy/app/components/slashed/inline-template.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; +import hbs from 'htmlbars-inline-precompile'; + +export default Component.extend({ + layout: hbs` +

Inline slashed component rendering test {{myName}}

+ `, + myName: 'slashed/inline-template' +}); \ No newline at end of file diff --git a/tests/dummy/app/components/slashed/js-only.js b/tests/dummy/app/components/slashed/js-only.js new file mode 100644 index 0000000..b4ff271 --- /dev/null +++ b/tests/dummy/app/components/slashed/js-only.js @@ -0,0 +1,8 @@ +import Component from '@ember/component'; +export default Component.extend({ + tagName: 'div', + classNames: ['slashed-pod__js-only'], + didRender() { + this.element.innerHTML = ''; + } +}); diff --git a/tests/dummy/app/components/slashed/mixed-classic.js b/tests/dummy/app/components/slashed/mixed-classic.js new file mode 100644 index 0000000..5ec458f --- /dev/null +++ b/tests/dummy/app/components/slashed/mixed-classic.js @@ -0,0 +1,6 @@ +import Component from '@ember/component'; +import layout from '../../templates/components/slashed/mixed-classic'; + +export default Component.extend({ + layout +}); diff --git a/tests/dummy/app/resolver.js b/tests/dummy/app/resolver.js index f47c78e..23e8e0c 100644 --- a/tests/dummy/app/resolver.js +++ b/tests/dummy/app/resolver.js @@ -1,4 +1,13 @@ import Resolver from 'ember-resolver'; import HotReloadMixin from 'ember-cli-hot-loader/mixins/hot-reload-resolver'; +import Mixin from '@ember/object/mixin'; -export default Resolver.extend(HotReloadMixin); \ No newline at end of file +const CustomHotReloadMixin = Mixin.create(HotReloadMixin, { + shouldExcludeComponent({name}) { + const excludedFromConfig = this._super(...arguments); + const isSlashedComponent = name.startsWith('excluded-slashed'); + return excludedFromConfig || isSlashedComponent; + } +}); + +export default Resolver.extend(CustomHotReloadMixin); \ No newline at end of file diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs index 0a12b33..6a54598 100644 --- a/tests/dummy/app/templates/application.hbs +++ b/tests/dummy/app/templates/application.hbs @@ -24,3 +24,40 @@ JS Only pod: {{js-only-pod}} {{dom-evented classNames="dom-evented"}}

component-with-actions using classic actions (not supported atm)

{{component-with-actions classNames="component-with-actions--classic" componentAction="routeAction"}} + +

slashed js-only component rendering test

+{{slashed/js-only}} +

slashed template-only component rendering test

+{{slashed/template-only}} +

slashed inline-template component rendering test

+{{slashed/inline-template}} +

slashed mixed-classic component rendering test

+{{slashed/mixed-classic}} + +

slashed podded js-only component rendering test

+{{slashed-pod/js-only}} +

slashed podded template-only component rendering test

+{{slashed-pod/template-only}} +

slashed podded inline-template component rendering test

+{{slashed-pod/inline-template}} +

slashed podded mixed-classic component rendering test

+{{slashed-pod/mixed-classic}} + +

excluded-slashed js-only component rendering test

+{{#excluded-slashed/js-only}}1{{/excluded-slashed/js-only}} +

excluded-slashed template-only component rendering test

+{{excluded-slashed/template-only}} +

excluded-slashed inline-template component rendering test

+{{excluded-slashed/inline-template}} +

excluded-slashed mixed-classic component rendering test

+{{excluded-slashed/mixed-classic}} + + +

excluded-slashed podded js-only component rendering test

+{{excluded-slashed-pod/js-only}} +

excluded-slashed podded template-only component rendering test

+{{excluded-slashed-pod/template-only}} +

excluded-slashed podded inline-template component rendering test

+{{excluded-slashed-pod/inline-template}} +

excluded-slashed podded mixed-classic component rendering test

+{{excluded-slashed-pod/mixed-classic}} \ No newline at end of file diff --git a/tests/dummy/app/templates/components/excluded-slashed/mixed-classic.hbs b/tests/dummy/app/templates/components/excluded-slashed/mixed-classic.hbs new file mode 100644 index 0000000..5b5efc8 --- /dev/null +++ b/tests/dummy/app/templates/components/excluded-slashed/mixed-classic.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file diff --git a/tests/dummy/app/templates/components/excluded-slashed/template-only.hbs b/tests/dummy/app/templates/components/excluded-slashed/template-only.hbs new file mode 100644 index 0000000..6c2920f --- /dev/null +++ b/tests/dummy/app/templates/components/excluded-slashed/template-only.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file diff --git a/tests/dummy/app/templates/components/slashed/mixed-classic.hbs b/tests/dummy/app/templates/components/slashed/mixed-classic.hbs new file mode 100644 index 0000000..f28816f --- /dev/null +++ b/tests/dummy/app/templates/components/slashed/mixed-classic.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file diff --git a/tests/dummy/app/templates/components/slashed/template-only.hbs b/tests/dummy/app/templates/components/slashed/template-only.hbs new file mode 100644 index 0000000..0406dc9 --- /dev/null +++ b/tests/dummy/app/templates/components/slashed/template-only.hbs @@ -0,0 +1,2 @@ +{{yield}} + \ No newline at end of file