mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 09:31:19 +02:00
Compare commits
2 Commits
12bfa9e83d
...
486d274be6
Author | SHA1 | Date | |
---|---|---|---|
|
486d274be6 | ||
|
ab3d2a944c |
@@ -4,9 +4,10 @@ This changelog goes through the changes that have been made in each release
|
||||
without substantial changes to our git log; to see the highlights of what has
|
||||
been added to each release, please refer to the [blog](https://blog.gitea.com).
|
||||
|
||||
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-12
|
||||
## [1.24.3](https://github.com/go-gitea/gitea/releases/tag/1.24.3) - 2025-07-15
|
||||
|
||||
* BUGFIXES
|
||||
* Fix form property assignment edge case (#35073) (#35078)
|
||||
* Improve submodule relative path handling (#35056) (#35075)
|
||||
* Fix incorrect comment diff hunk parsing, fix github asset ID nil panic (#35046) (#35055)
|
||||
* Fix updating user visibility (#35036) (#35044)
|
||||
|
@@ -1,12 +1,23 @@
|
||||
import {assignElementProperty} from './common-button.ts';
|
||||
import {assignElementProperty, type ElementWithAssignableProperties} from './common-button.ts';
|
||||
|
||||
test('assignElementProperty', () => {
|
||||
const elForm = document.createElement('form');
|
||||
assignElementProperty(elForm, 'action', '/test-link');
|
||||
expect(elForm.action).contains('/test-link'); // the DOM always returns absolute URL
|
||||
expect(elForm.getAttribute('action')).eq('/test-link');
|
||||
assignElementProperty(elForm, 'text-content', 'dummy');
|
||||
expect(elForm.textContent).toBe('dummy');
|
||||
|
||||
// mock a form with its property "action" overwritten by an input element
|
||||
const elFormWithAction = new class implements ElementWithAssignableProperties {
|
||||
action = document.createElement('input'); // now "form.action" is not string, but an input element
|
||||
_attrs: Record<string, string> = {};
|
||||
setAttribute(name: string, value: string) { this._attrs[name] = value }
|
||||
getAttribute(name: string): string | null { return this._attrs[name] }
|
||||
}();
|
||||
assignElementProperty(elFormWithAction, 'action', '/bar');
|
||||
expect(elFormWithAction.getAttribute('action')).eq('/bar');
|
||||
|
||||
const elInput = document.createElement('input');
|
||||
expect(elInput.readOnly).toBe(false);
|
||||
assignElementProperty(elInput, 'read-only', 'true');
|
||||
|
@@ -102,18 +102,26 @@ function onHidePanelClick(el: HTMLElement, e: MouseEvent) {
|
||||
throw new Error('no panel to hide'); // should never happen, otherwise there is a bug in code
|
||||
}
|
||||
|
||||
export function assignElementProperty(el: any, name: string, val: string) {
|
||||
name = camelize(name);
|
||||
const old = el[name];
|
||||
export type ElementWithAssignableProperties = {
|
||||
getAttribute: (name: string) => string | null;
|
||||
setAttribute: (name: string, value: string) => void;
|
||||
} & Record<string, any>
|
||||
|
||||
export function assignElementProperty(el: ElementWithAssignableProperties, kebabName: string, val: string) {
|
||||
const camelizedName = camelize(kebabName);
|
||||
const old = el[camelizedName];
|
||||
if (typeof old === 'boolean') {
|
||||
el[name] = val === 'true';
|
||||
el[camelizedName] = val === 'true';
|
||||
} else if (typeof old === 'number') {
|
||||
el[name] = parseFloat(val);
|
||||
el[camelizedName] = parseFloat(val);
|
||||
} else if (typeof old === 'string') {
|
||||
el[name] = val;
|
||||
el[camelizedName] = val;
|
||||
} else if (old?.nodeName) {
|
||||
// "form" has an edge case: its "<input name=action>" element overwrites the "action" property, we can only set attribute
|
||||
el.setAttribute(kebabName, val);
|
||||
} else {
|
||||
// in the future, we could introduce a better typing system like `data-modal-form.action:string="..."`
|
||||
throw new Error(`cannot assign element property ${name} by value ${val}`);
|
||||
throw new Error(`cannot assign element property "${camelizedName}" by value "${val}"`);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user