From a99a7646d4aa22025de65b57d479b65bef0cfb96 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sat, 1 May 2021 01:18:16 +0900 Subject: Element.currentStyle を新規翻訳 (#520) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2020/12/23 時点の英語版に基づき新規翻訳 --- files/ja/web/api/element/currentstyle/index.html | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 files/ja/web/api/element/currentstyle/index.html (limited to 'files') diff --git a/files/ja/web/api/element/currentstyle/index.html b/files/ja/web/api/element/currentstyle/index.html new file mode 100644 index 0000000000..24548064d8 --- /dev/null +++ b/files/ja/web/api/element/currentstyle/index.html @@ -0,0 +1,50 @@ +--- +title: Element.currentStyle +slug: Web/API/Element/currentStyle +tags: + - API + - NeedsExample + - Non-standard + - Property +translation_of: Web/API/Element/currentStyle +--- +

{{Non-standard_header}}

+ +

Element.currentStyle は独自プロパティで、標準化されている {{DOMxRef("window.getComputedStyle()")}} メソッドに似ているものです。古いバージョンの Microsoft Internet Explorer で使用できます。しかし、 window.getComputedStyle() がピクセル数で値を返すのに対し、これは CSS で設定された単位で返します。

+ +

ポリフィル

+ +
+

このポリフィルは値をピクセル数で返しますが、値を読むたびに {{domxref("window.getComputedStyle()")}} を呼び出さなければならないため、かなり遅くなると思われます。

+
+ +
/* すべての著作権をパブリックドメインに寄贈します。
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+if (!("currentStyle" in Element.prototype)) {
+  Object.defineProperty(Element.prototype, "currentStyle", {
+    get: function() {
+      return window.getComputedStyle(this);
+    }
+  });
+}
+
+ +

仕様書

+ +

どの仕様書にも含まれていません。

+ +

Microsoft は MSDN で説明しています

+ +

ブラウザーの互換性

+ +

{{Compat("api.Element.currentStyle")}}

+ +

関連情報

+ + + +
{{APIRef("DOM")}}
-- cgit v1.2.3-54-g00ecf