Skip to content

Rebuild js dist files #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Dropzone/Resources/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class default_1 extends Controller {
});
reader.readAsDataURL(file);
}
_dispatchEvent(name, payload) {
_dispatchEvent(name, payload = {}) {
this.element.dispatchEvent(new CustomEvent(name, { detail: payload }));
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/LazyImage/Resources/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Controller } from '@hotwired/stimulus';
class default_1 extends Controller {
connect() {
const hd = new Image();
const element = this.element;
const srcsetString = this._calculateSrcsetString();
hd.addEventListener('load', () => {
this.element.src = this.srcValue;
element.src = this.srcValue;
if (srcsetString) {
this.element.srcset = srcsetString;
element.srcset = srcsetString;
}
this._dispatchEvent('lazy-image:ready', { image: hd });
});
Expand Down
70 changes: 42 additions & 28 deletions src/LiveComponent/assets/dist/live_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ function setDeepData(data, propertyPath, value) {
const finalKey = parts[parts.length - 1];
if (typeof currentLevelData !== 'object') {
const lastPart = parts.pop();
throw new Error(`Cannot set data-model="${propertyPath}". They parent "${parts.join(',')}" data does not appear to be an object (it's "${currentLevelData}"). Did you forget to add exposed={"${lastPart}"} to its LiveProp?`);
throw new Error(`Cannot set data-model="${propertyPath}". The parent "${parts.join('.')}" data does not appear to be an object (it's "${currentLevelData}"). Did you forget to add exposed={"${lastPart}"} to its LiveProp?`);
}
if (currentLevelData[finalKey] === undefined) {
const lastPart = parts.pop();
Expand Down Expand Up @@ -1014,6 +1014,26 @@ function haveRenderedValuesChanged(originalDataJson, currentDataJson, newDataJso
return keyHasChanged;
}

function normalizeAttributesForComparison(element) {
if (element.value) {
element.setAttribute('value', element.value);
}
else if (element.hasAttribute('value')) {
element.setAttribute('value', '');
}
Array.from(element.children).forEach((child) => {
normalizeAttributesForComparison(child);
});
}

function cloneHTMLElement(element) {
const newElement = element.cloneNode(true);
if (!(newElement instanceof HTMLElement)) {
throw new Error('Could not clone element');
}
return newElement;
}

const DEFAULT_DEBOUNCE = 150;
class default_1 extends Controller {
constructor() {
Expand Down Expand Up @@ -1112,23 +1132,12 @@ class default_1 extends Controller {
this._makeRequest(null);
}
_getValueFromElement(element) {
const value = element.dataset.value || element.value;
if (!value) {
const clonedElement = (element.cloneNode());
if (!(clonedElement instanceof HTMLElement)) {
throw new Error('cloneNode() produced incorrect type');
}
throw new Error(`The update() method could not be called for "${clonedElement.outerHTML}": the element must either have a "data-value" or "value" attribute set.`);
}
return value;
return element.dataset.value || element.value;
}
_updateModelFromElement(element, value, shouldRender) {
const model = element.dataset.model || element.getAttribute('name');
if (!model) {
const clonedElement = (element.cloneNode());
if (!(clonedElement instanceof HTMLElement)) {
throw new Error('cloneNode() produced incorrect type');
}
const clonedElement = cloneHTMLElement(element);
throw new Error(`The update() method could not be called for "${clonedElement.outerHTML}": the element must either have a "data-model" or "name" attribute set to the model name.`);
}
this.$updateModel(model, value, shouldRender, element.hasAttribute('name') ? element.getAttribute('name') : null);
Expand Down Expand Up @@ -1183,7 +1192,7 @@ class default_1 extends Controller {
}
const fetchOptions = {};
fetchOptions.headers = {
'Accept': 'application/vnd.live-component+json',
'Accept': 'application/vnd.live-component+html',
};
if (action) {
url += `/${encodeURIComponent(action)}`;
Expand All @@ -1209,34 +1218,30 @@ class default_1 extends Controller {
}
const isMostRecent = this.renderPromiseStack.removePromise(thisPromise);
if (isMostRecent) {
response.json().then((data) => {
this._processRerender(data);
response.text().then((html) => {
this._processRerender(html, response);
});
}
});
}
_processRerender(data) {
_processRerender(html, response) {
if (this.isWindowUnloaded) {
return;
}
if (data.redirect_url) {
if (response.headers.get('Location')) {
if (typeof Turbo !== 'undefined') {
Turbo.visit(data.redirect_url);
Turbo.visit(response.headers.get('Location'));
}
else {
window.location.href = data.redirect_url;
window.location.href = response.headers.get('Location') || '';
}
return;
}
if (!this._dispatchEvent('live:render', data, true, true)) {
if (!this._dispatchEvent('live:render', html, true, true)) {
return;
}
this._onLoadingFinish();
if (!data.html) {
throw new Error('Missing html key on response JSON');
}
this._executeMorphdom(data.html);
this.dataValue = data.data;
this._executeMorphdom(html);
}
_clearWaitingDebouncedRenders() {
if (this.renderDebounceTimeout) {
Expand Down Expand Up @@ -1371,7 +1376,13 @@ class default_1 extends Controller {
morphdom(this.element, newElement, {
onBeforeElUpdated: (fromEl, toEl) => {
if (fromEl.isEqualNode(toEl)) {
return false;
const normalizedFromEl = cloneHTMLElement(fromEl);
normalizeAttributesForComparison(normalizedFromEl);
const normalizedToEl = cloneHTMLElement(toEl);
normalizeAttributesForComparison(normalizedToEl);
if (normalizedFromEl.isEqualNode(normalizedToEl)) {
return false;
}
}
const controllerName = fromEl.hasAttribute('data-controller') ? fromEl.getAttribute('data-controller') : null;
if (controllerName
Expand All @@ -1380,6 +1391,9 @@ class default_1 extends Controller {
&& !this._shouldChildLiveElementUpdate(fromEl, toEl)) {
return false;
}
if (fromEl.hasAttribute('data-live-ignore')) {
return false;
}
return true;
}
});
Expand Down