Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix style undefined with hmr#1040

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vallemar wants to merge3 commits intonativescript-vue:mainfromvallemar:fix-hmr-style
Closed
Changes fromall 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
18 changes: 14 additions & 4 deletionssrc/renderer/modules/style.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
import { NSVElement } from "../../dom";
import { NormalizedStyle } from "@vue/shared";

type Style = string | null;
type Style = string |Record<string, string | number> |null;

function normalizeStyle(style: NormalizedStyle | Style): NormalizedStyle {
if (!style) {
return null;
}

if (typeof style === "string" && style?.trim().charAt(0) === "{") {
return JSON.parse(style);
if (typeof style === "string") {
if (style?.trim().charAt(0) === "{") {
return JSON.parse(style);
}
// todo: check if a style can be a string but not json?
}

return style as NormalizedStyle;
Expand DownExpand Up@@ -51,7 +54,14 @@ function removeStyleProperty(el: NSVElement, property: string) {
// changing the attribute will not update our originalValue, so when removing
// the previous color will be applied. Fixing this would involve listening to
// individual attribute changes, and it's not worth the overhead.
el.style[property] = originalValue;
try {
el.style[property] = originalValue;
} catch (err) {
// hack: if the original value is invalid, we can't set it back to it's original value
// instead we set it to null, which will remove the style, however this may
// still lead to incorrect styling in some cases.
el.style[property] = null;
}
}
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp