Skip to content

Commit

Permalink
5.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Feb 28, 2021
1 parent 1b3b7c8 commit 8f8e537
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 170 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "riot",
"version": "5.3.0",
"version": "5.3.1",
"description": "Simple and elegant component-based UI library",
"homepage": "http://riot.js.org/",
"repository": "riot/riot",
Expand Down
139 changes: 77 additions & 62 deletions riot+compiler.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions riot+compiler.min.js

Large diffs are not rendered by default.

111 changes: 60 additions & 51 deletions riot.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Riot v5.3.0, @license MIT */
/* Riot v5.3.1, @license MIT */
/**
* Convert a string from camel case to dash-case
* @param {string} string - probably a component tag name
Expand Down Expand Up @@ -86,9 +86,9 @@ const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refN
const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);

// Riot.js constants that can be used accross more modules
const COMPONENTS_IMPLEMENTATION_MAP = new Map(),
DOM_COMPONENT_INSTANCE_PROPERTY = Symbol('riot-component'),
PLUGINS_SET = new Set(),
const COMPONENTS_IMPLEMENTATION_MAP$1 = new Map(),
DOM_COMPONENT_INSTANCE_PROPERTY$1 = Symbol('riot-component'),
PLUGINS_SET$1 = new Set(),
IS_DIRECTIVE = 'is',
VALUE_ATTRIBUTE = 'value',
MOUNT_METHOD_KEY = 'mount',
Expand All @@ -105,16 +105,17 @@ const COMPONENTS_IMPLEMENTATION_MAP = new Map(),
STATE_KEY = 'state',
SLOTS_KEY = 'slots',
ROOT_KEY = 'root',
IS_PURE_SYMBOL = Symbol.for('pure'),
IS_PURE_SYMBOL = Symbol('pure'),
IS_COMPONENT_UPDATING = Symbol('is_updating'),
PARENT_KEY_SYMBOL = Symbol('parent'),
ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
TEMPLATE_KEY_SYMBOL = Symbol('template');

var globals = /*#__PURE__*/Object.freeze({
__proto__: null,
COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP,
DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY,
PLUGINS_SET: PLUGINS_SET,
COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
PLUGINS_SET: PLUGINS_SET$1,
IS_DIRECTIVE: IS_DIRECTIVE,
VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
Expand All @@ -132,6 +133,7 @@ var globals = /*#__PURE__*/Object.freeze({
SLOTS_KEY: SLOTS_KEY,
ROOT_KEY: ROOT_KEY,
IS_PURE_SYMBOL: IS_PURE_SYMBOL,
IS_COMPONENT_UPDATING: IS_COMPONENT_UPDATING,
PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
Expand Down Expand Up @@ -662,7 +664,7 @@ function createPatch(items, scope, parentScope, binding) {
};
}

function create(node, _ref2) {
function create$6(node, _ref2) {
let {
evaluate,
condition,
Expand Down Expand Up @@ -741,7 +743,7 @@ const IfBinding = {
}

};
function create$1(node, _ref) {
function create$5(node, _ref) {
let {
evaluate,
template
Expand Down Expand Up @@ -1077,7 +1079,7 @@ function apply(expression, value) {
return expressions[expression.type](expression.node, expression, value, expression.value);
}

function create$2(node, data) {
function create$4(node, data) {
return Object.assign({}, Expression, data, {
node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
});
Expand Down Expand Up @@ -1105,7 +1107,7 @@ function create$3(node, _ref) {
let {
expressions
} = _ref;
return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$2(node, expression)), ['mount', 'update', 'unmount']));
return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$4(node, expression)), ['mount', 'update', 'unmount']));
}

function extendParentScope(attributes, scope, parentScope) {
Expand Down Expand Up @@ -1143,7 +1145,7 @@ const SlotBinding = {
parentNode
} = this.node;
const realParent = getRealParent(scope, parentScope);
this.template = templateData && create$6(templateData.html, templateData.bindings).createDOM(parentNode);
this.template = templateData && create(templateData.html, templateData.bindings).createDOM(parentNode);

if (this.template) {
this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
Expand Down Expand Up @@ -1232,7 +1234,7 @@ function getTag(component, slots, attributes) {
} // otherwise we return a template chunk


return create$6(slotsToMarkup(slots), [...slotBindings(slots), {
return create(slotsToMarkup(slots), [...slotBindings(slots), {
// the attributes should be registered as binding
// if we fallback to a normal template chunk
expressions: attributes.map(attr => {
Expand Down Expand Up @@ -1310,7 +1312,7 @@ const TagBinding = {
}

};
function create$4(node, _ref2) {
function create$2(node, _ref2) {
let {
evaluate,
getComponent,
Expand All @@ -1327,10 +1329,10 @@ function create$4(node, _ref2) {
}

var bindings = {
[IF]: create$1,
[IF]: create$5,
[SIMPLE]: create$3,
[EACH]: create,
[TAG]: create$4,
[EACH]: create$6,
[TAG]: create$2,
[SLOT]: createSlot
};

Expand All @@ -1356,7 +1358,7 @@ function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
*/


function create$5(root, binding, templateTagOffset) {
function create$1(root, binding, templateTagOffset) {
const {
selector,
type,
Expand Down Expand Up @@ -1507,7 +1509,7 @@ const TemplateChunk = Object.freeze({

if (!avoidDOMInjection && this.fragment) injectDOM(el, this.fragment); // create the bindings

this.bindings = this.bindingsData.map(binding => create$5(this.el, binding, templateTagOffset));
this.bindings = this.bindingsData.map(binding => create$1(this.el, binding, templateTagOffset));
this.bindings.forEach(b => b.mount(scope, parentScope)); // store the template meta properties

this.meta = meta;
Expand Down Expand Up @@ -1585,7 +1587,7 @@ const TemplateChunk = Object.freeze({
* @returns {TemplateChunk} a new TemplateChunk copy
*/

function create$6(html, bindings) {
function create(html, bindings) {
if (bindings === void 0) {
bindings = [];
}
Expand Down Expand Up @@ -1656,9 +1658,9 @@ function create$6(html, bindings) {

var DOMBindings = /*#__PURE__*/Object.freeze({
__proto__: null,
template: create$6,
createBinding: create$5,
createExpression: create$2,
template: create,
createBinding: create$1,
createExpression: create$4,
bindingTypes: bindingTypes,
expressionTypes: expressionTypes
});
Expand Down Expand Up @@ -2014,7 +2016,7 @@ function evaluateInitialProps(element, initialProps) {
*/


const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY] = component;
const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY$1] = component;
/**
* Wrap the Riot.js core API methods using a mapping function
* @param {Function} mapFunction - lifting function
Expand All @@ -2038,11 +2040,11 @@ function createCoreAPIMethods(mapFunction) {

function componentTemplateFactory(template, componentShell) {
const components = createSubcomponents(componentShell.exports ? componentShell.exports.components : {});
return template(create$6, expressionTypes, bindingTypes, name => {
return template(create, expressionTypes, bindingTypes, name => {
// improve support for recursive components
if (name === componentShell.name) return memoizedCreateComponent(componentShell); // return the registered components

return components[name] || COMPONENTS_IMPLEMENTATION_MAP.get(name);
return components[name] || COMPONENTS_IMPLEMENTATION_MAP$1.get(name);
});
}
/**
Expand Down Expand Up @@ -2195,7 +2197,7 @@ function createAttributeBindings(node, attributes) {
attributes = [];
}

const expressions = attributes.map(a => create$2(node, a));
const expressions = attributes.map(a => create$4(node, a));
const binding = {};
return Object.assign(binding, Object.assign({
expressions
Expand Down Expand Up @@ -2230,7 +2232,7 @@ function createSubcomponents(components) {


function runPlugins(component) {
return [...PLUGINS_SET].reduce((c, fn) => fn(c) || c, component);
return [...PLUGINS_SET$1].reduce((c, fn) => fn(c) || c, component);
}
/**
* Compute the component current state merging it with its previous state
Expand Down Expand Up @@ -2312,9 +2314,16 @@ function enhanceComponentAPI(component, _ref5) {
if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
this[STATE_KEY] = computeState(this[STATE_KEY], state);
this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]);
this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
// see also https://github.com/riot/riot/issues/2895

if (!this[IS_COMPONENT_UPDATING]) {
this[IS_COMPONENT_UPDATING] = true;
this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
}

this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
this[IS_COMPONENT_UPDATING] = false;
return this;
},

Expand All @@ -2340,8 +2349,8 @@ function enhanceComponentAPI(component, _ref5) {

function mountComponent(element, initialProps, componentName) {
const name = componentName || getName(element);
if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component named "${name}" was never registered`);
const component = COMPONENTS_IMPLEMENTATION_MAP.get(name)({
if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component named "${name}" was never registered`);
const component = COMPONENTS_IMPLEMENTATION_MAP$1.get(name)({
props: initialProps
});
return component.mount(element);
Expand Down Expand Up @@ -2373,9 +2382,9 @@ function compose() {
}

const {
DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
PLUGINS_SET: PLUGINS_SET$1
DOM_COMPONENT_INSTANCE_PROPERTY,
COMPONENTS_IMPLEMENTATION_MAP,
PLUGINS_SET
} = globals;
/**
* Riot public api
Expand All @@ -2394,14 +2403,14 @@ function register(name, _ref) {
template,
exports
} = _ref;
if (COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component "${name}" was already registered`);
COMPONENTS_IMPLEMENTATION_MAP$1.set(name, createComponent({
if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponent({
name,
css,
template,
exports
}));
return COMPONENTS_IMPLEMENTATION_MAP$1;
return COMPONENTS_IMPLEMENTATION_MAP;
}
/**
* Unregister a riot web component
Expand All @@ -2410,10 +2419,10 @@ function register(name, _ref) {
*/

function unregister(name) {
if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component "${name}" was never registered`);
COMPONENTS_IMPLEMENTATION_MAP$1.delete(name);
if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
COMPONENTS_IMPLEMENTATION_MAP.delete(name);
cssManager.remove(name);
return COMPONENTS_IMPLEMENTATION_MAP$1;
return COMPONENTS_IMPLEMENTATION_MAP;
}
/**
* Mounting function that will work only for the components that were globally registered
Expand All @@ -2435,8 +2444,8 @@ function mount(selector, initialProps, name) {

function unmount(selector, keepRootElement) {
return $(selector).map(element => {
if (element[DOM_COMPONENT_INSTANCE_PROPERTY$1]) {
element[DOM_COMPONENT_INSTANCE_PROPERTY$1].unmount(keepRootElement);
if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
}

return element;
Expand All @@ -2450,9 +2459,9 @@ function unmount(selector, keepRootElement) {

function install(plugin) {
if (!isFunction(plugin)) panic('Plugins must be of type function');
if (PLUGINS_SET$1.has(plugin)) panic('This plugin was already installed');
PLUGINS_SET$1.add(plugin);
return PLUGINS_SET$1;
if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
PLUGINS_SET.add(plugin);
return PLUGINS_SET;
}
/**
* Uninstall a riot plugin
Expand All @@ -2461,9 +2470,9 @@ function install(plugin) {
*/

function uninstall(plugin) {
if (!PLUGINS_SET$1.has(plugin)) panic('This plugin was never installed');
PLUGINS_SET$1.delete(plugin);
return PLUGINS_SET$1;
if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
PLUGINS_SET.delete(plugin);
return PLUGINS_SET;
}
/**
* Helper method to create component without relying on the registered ones
Expand Down Expand Up @@ -2498,7 +2507,7 @@ function pure(func) {
}
/** @type {string} current riot version */

const version = 'v5.3.0'; // expose some internal stuff that might be used from external tools
const version = 'v5.3.1'; // expose some internal stuff that might be used from external tools

const __ = {
cssManager,
Expand Down
Loading

0 comments on commit 8f8e537

Please sign in to comment.