Skip to content

Commit

Permalink
fix bug with last release and modules not loading when context wasn't…
Browse files Browse the repository at this point in the history
… set
  • Loading branch information
rikschennink committed Sep 28, 2019
1 parent 35018c9 commit c225928
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions conditioner-core.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* conditioner-core 2.3.2 */
/* conditioner-core 2.3.3 */
// links the module to the element and exposes a callback api object
const bindModule = (element, unbind) => {
// gets the name of the module from the element, we assume the name is an alias
Expand Down Expand Up @@ -289,7 +289,7 @@ const createModule = element => {
const query = runPlugin('moduleGetContext', element);

// wait for the right context or load the module immidiately if no context supplied
const monitor = createContextualModule(query, boundModule);
const monitor = query && createContextualModule(query, boundModule);

// return module
return query ? boundModule : boundModule.mount();
Expand Down
4 changes: 2 additions & 2 deletions conditioner-core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* conditioner-core 2.3.2 */
/* conditioner-core 2.3.3 */
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['exports'], factory);
Expand Down Expand Up @@ -368,7 +368,7 @@
var query = runPlugin('moduleGetContext', element);

// wait for the right context or load the module immidiately if no context supplied
var monitor = createContextualModule(query, boundModule);
var monitor = query && createContextualModule(query, boundModule);

// return module
return query ? boundModule : boundModule.mount();
Expand Down
4 changes: 2 additions & 2 deletions conditioner-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Resize the window, when it's wider than 40em Conditioner will unmount the SectionToggler
-->

<h2 data-module="sectionToggler" data-context="@media (max-width:40em)">Frizz free, context-aware, JavaScript modules</h2>
<h2 data-module="SectionToggler" data-context="@media (max-width:40em)">Frizz free, context-aware, JavaScript modules</h2>
<div>

<p>Building a content based website?</p>
Expand All @@ -64,10 +64,18 @@ <h2 data-module="sectionToggler" data-context="@media (max-width:40em)">Frizz fr

</div>

<h2>Let's print "Hello World"</h2>
<p data-module="HelloWorld"></p>

<script src="conditioner-core.min.js"></script>
<script>
// Our Accessible Section toggler module
var sectionToggler = (element) => {
// Our Hello World module
function HelloWorld(element) {
element.textContent = 'Hello World';
};

// Our Section Toggler module
function SectionToggler(element) {

// get section to toggle so we can hide it
const target = element.nextElementSibling;
Expand All @@ -88,7 +96,7 @@ <h2 data-module="sectionToggler" data-context="@media (max-width:40em)">Frizz fr
target.hidden = true;

// clean up method
return () => {
return function() {
element.nextElementSibling.hidden = false;
element.textContent = element.firstChild.textContent;
};
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const createModule = element => {
const query = runPlugin('moduleGetContext', element);

// wait for the right context or load the module immidiately if no context supplied
const monitor = createContextualModule(query, boundModule);
const monitor = query && createContextualModule(query, boundModule);

// return module
return query ? boundModule : boundModule.mount();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "conditioner-core",
"version": "2.3.2",
"version": "2.3.3",
"description": "Conditioner - Frizz free, context-aware, JavaScript modules",
"homepage": "https://pqina.nl/conditioner",
"main": "conditioner-core.js",
Expand Down

0 comments on commit c225928

Please sign in to comment.