From 1afd214b4c6ed965b75ece5e8d75febad8bc7c07 Mon Sep 17 00:00:00 2001 From: MDN Date: Thu, 27 May 2021 00:56:56 +0000 Subject: [CRON] sync translated content --- files/es/_redirects.txt | 1 + files/es/_wikihistory.json | 12 +- .../web/api/childnode/replacewith/index.html | 142 +++++++++++++++++++++ files/es/web/api/childnode/replacewith/index.html | 141 -------------------- files/fr/_redirects.txt | 1 + files/fr/_wikihistory.json | 18 +-- .../web/api/childnode/replacewith/index.html | 118 +++++++++++++++++ files/fr/web/api/childnode/replacewith/index.html | 117 ----------------- files/ja/_redirects.txt | 1 + files/ja/_wikihistory.json | 14 +- .../web/api/childnode/replacewith/index.html | 120 +++++++++++++++++ files/ja/web/api/childnode/replacewith/index.html | 119 ----------------- files/ru/_redirects.txt | 1 + files/ru/_wikihistory.json | 12 +- .../web/api/childnode/replacewith/index.html | 114 +++++++++++++++++ files/ru/web/api/childnode/replacewith/index.html | 113 ---------------- files/zh-cn/_redirects.txt | 1 + files/zh-cn/_wikihistory.json | 18 +-- .../web/api/childnode/replacewith/index.html | 112 ++++++++++++++++ .../zh-cn/web/api/childnode/replacewith/index.html | 111 ---------------- 20 files changed, 648 insertions(+), 638 deletions(-) create mode 100644 files/es/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/es/web/api/childnode/replacewith/index.html create mode 100644 files/fr/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/fr/web/api/childnode/replacewith/index.html create mode 100644 files/ja/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/ja/web/api/childnode/replacewith/index.html create mode 100644 files/ru/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/ru/web/api/childnode/replacewith/index.html create mode 100644 files/zh-cn/orphaned/web/api/childnode/replacewith/index.html delete mode 100644 files/zh-cn/web/api/childnode/replacewith/index.html diff --git a/files/es/_redirects.txt b/files/es/_redirects.txt index 0b38f00189..d63ef58754 100644 --- a/files/es/_redirects.txt +++ b/files/es/_redirects.txt @@ -1780,6 +1780,7 @@ /es/docs/Web/API/CameraCapabilities.maxFocusAreas /es/docs/Web/API/CameraCapabilities/maxFocusAreas /es/docs/Web/API/Canvas_API/Tutorial/Compositing/Ejemplo /es/docs/Web/API/Canvas_API/Tutorial/Compositing/Example /es/docs/Web/API/ChildNode/remove /es/docs/orphaned/Web/API/ChildNode/remove +/es/docs/Web/API/ChildNode/replaceWith /es/docs/orphaned/Web/API/ChildNode/replaceWith /es/docs/Web/API/Console/tabla /es/docs/Web/API/Console/table /es/docs/Web/API/Constraint_validation/invalid_event /es/docs/Web/API/HTMLInputElement/invalid_event /es/docs/Web/API/Coordinates /es/docs/Web/API/GeolocationCoordinates diff --git a/files/es/_wikihistory.json b/files/es/_wikihistory.json index 7478c48f7a..3ffc1ff3a1 100644 --- a/files/es/_wikihistory.json +++ b/files/es/_wikihistory.json @@ -5547,12 +5547,6 @@ "SoftwareRVG" ] }, - "Web/API/ChildNode/replaceWith": { - "modified": "2019-03-23T22:23:34.633Z", - "contributors": [ - "SoftwareRVG" - ] - }, "Web/API/ClipboardEvent": { "modified": "2020-10-15T22:14:15.464Z", "contributors": [ @@ -23431,6 +23425,12 @@ "SoftwareRVG" ] }, + "orphaned/Web/API/ChildNode/replaceWith": { + "modified": "2019-03-23T22:23:34.633Z", + "contributors": [ + "SoftwareRVG" + ] + }, "orphaned/Web/API/Detecting_device_orientation": { "modified": "2020-08-11T08:30:00.189Z", "contributors": [ diff --git a/files/es/orphaned/web/api/childnode/replacewith/index.html b/files/es/orphaned/web/api/childnode/replacewith/index.html new file mode 100644 index 0000000000..a9aa23ce79 --- /dev/null +++ b/files/es/orphaned/web/api/childnode/replacewith/index.html @@ -0,0 +1,142 @@ +--- +title: ChildNode.replaceWith() +slug: orphaned/Web/API/ChildNode/replaceWith +tags: + - API + - DOM + - Experimental + - Nodo + - Referencia + - metodo +translation_of: Web/API/ChildNode/replaceWith +original_slug: Web/API/ChildNode/replaceWith +--- +

{{APIRef ( "DOM")}} {{SeeCompatTable}}
+
+ El método ChildNode.replaceWith () reemplaza este ChildNode en la lista de hijos de su padre con un conjunto de objetos {{domxref ( "Node")}} o {{domxref ( "DOMString")}}. Los objetos {{domxref ( "DOMString")}} se insertan como nodos equivalentes {{domxref ( "Text")}}.

+ +

 

+ +

Síntasix

+ +

 

+ +
[Throws, Unscopable]
+void ChildNode.replaceWith((Node or DOMString)... nodes);
+
+ +

Parámetros

+ +
+
nodos
+
Un conjunto de objetos {{domxref ( "Node")}} o {{domxref ( "DOMString")}} para reemplazar.
+
+ +

Excepciones

+ + + +

Ejemplos

+ +

Utilizando replaceWith()

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span></div>"
+
+ +

ChildNode.replaceWith() es unscopable

+ +

El método replaceWith () no está incluido en la declaracion with. Consulte {{jsxref ( "Symbol.unscopables")}} para obtener más información.

+ +
with(node) {
+  replaceWith("foo");
+}
+// ReferenceError: replaceWith is not defined 
+ +

Especificación

+ + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Definición Inicial.
+ +

Compatibilidad en los Navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FunciónChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte Básico{{CompatChrome(54.0)}}{{CompatGeckoDesktop(49)}}{{CompatUnknown}}{{CompatOpera(39)}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
FunciónAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Mobile
Soporte Básico{{CompatNo}}{{CompatChrome(54.0)}}{{CompatGeckoMobile(49)}}{{CompatUnknown}}{{CompatOperaMobile(39)}}{{CompatUnknown}}{{CompatChrome(54.0)}}
+
+ +

Ver También

+ + diff --git a/files/es/web/api/childnode/replacewith/index.html b/files/es/web/api/childnode/replacewith/index.html deleted file mode 100644 index 32f78b7e4e..0000000000 --- a/files/es/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,141 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: Web/API/ChildNode/replaceWith -tags: - - API - - DOM - - Experimental - - Nodo - - Referencia - - metodo -translation_of: Web/API/ChildNode/replaceWith ---- -

{{APIRef ( "DOM")}} {{SeeCompatTable}}
-
- El método ChildNode.replaceWith () reemplaza este ChildNode en la lista de hijos de su padre con un conjunto de objetos {{domxref ( "Node")}} o {{domxref ( "DOMString")}}. Los objetos {{domxref ( "DOMString")}} se insertan como nodos equivalentes {{domxref ( "Text")}}.

- -

 

- -

Síntasix

- -

 

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node or DOMString)... nodes);
-
- -

Parámetros

- -
-
nodos
-
Un conjunto de objetos {{domxref ( "Node")}} o {{domxref ( "DOMString")}} para reemplazar.
-
- -

Excepciones

- - - -

Ejemplos

- -

Utilizando replaceWith()

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() es unscopable

- -

El método replaceWith () no está incluido en la declaracion with. Consulte {{jsxref ( "Symbol.unscopables")}} para obtener más información.

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith is not defined 
- -

Especificación

- - - - - - - - - - - - - - -
EspecificaciónEstadoComentario
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Definición Inicial.
- -

Compatibilidad en los Navegadores

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FunciónChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte Básico{{CompatChrome(54.0)}}{{CompatGeckoDesktop(49)}}{{CompatUnknown}}{{CompatOpera(39)}}{{CompatUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
FunciónAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Mobile
Soporte Básico{{CompatNo}}{{CompatChrome(54.0)}}{{CompatGeckoMobile(49)}}{{CompatUnknown}}{{CompatOperaMobile(39)}}{{CompatUnknown}}{{CompatChrome(54.0)}}
-
- -

Ver También

- - diff --git a/files/fr/_redirects.txt b/files/fr/_redirects.txt index 22ba5716b9..311dd1cdf9 100644 --- a/files/fr/_redirects.txt +++ b/files/fr/_redirects.txt @@ -3615,6 +3615,7 @@ /fr/docs/Web/API/Canvas_API/Tutoriel_canvas/Utilisation_d'images /fr/docs/Web/API/Canvas_API/Tutorial/Using_images /fr/docs/Web/API/Canvas_API/Tutoriel_canvas/Utilisation_de_base /fr/docs/Web/API/Canvas_API/Tutorial/Basic_usage /fr/docs/Web/API/ChildNode/remove /fr/docs/orphaned/Web/API/ChildNode/remove +/fr/docs/Web/API/ChildNode/replaceWith /fr/docs/orphaned/Web/API/ChildNode/replaceWith /fr/docs/Web/API/Commentaire /fr/docs/Web/API/Comment /fr/docs/Web/API/Commentaire/Comment /fr/docs/Web/API/Comment/Comment /fr/docs/Web/API/Console.table /fr/docs/Web/API/Console/table diff --git a/files/fr/_wikihistory.json b/files/fr/_wikihistory.json index 99ed1bb69a..dce94aa003 100644 --- a/files/fr/_wikihistory.json +++ b/files/fr/_wikihistory.json @@ -13087,15 +13087,6 @@ "loella16" ] }, - "Web/API/ChildNode/replaceWith": { - "modified": "2020-10-15T21:55:03.476Z", - "contributors": [ - "tristantheb", - "loella16", - "Spictheweb", - "v-Stein" - ] - }, "Web/API/Client": { "modified": "2020-11-16T08:56:05.543Z", "contributors": [ @@ -45034,6 +45025,15 @@ "Copen" ] }, + "orphaned/Web/API/ChildNode/replaceWith": { + "modified": "2020-10-15T21:55:03.476Z", + "contributors": [ + "tristantheb", + "loella16", + "Spictheweb", + "v-Stein" + ] + }, "orphaned/Web/API/Detecting_device_orientation": { "modified": "2019-03-23T23:28:22.437Z", "contributors": [ diff --git a/files/fr/orphaned/web/api/childnode/replacewith/index.html b/files/fr/orphaned/web/api/childnode/replacewith/index.html new file mode 100644 index 0000000000..675e7c6026 --- /dev/null +++ b/files/fr/orphaned/web/api/childnode/replacewith/index.html @@ -0,0 +1,118 @@ +--- +title: ChildNode.replaceWith() +slug: orphaned/Web/API/ChildNode/replaceWith +tags: + - API + - DOM + - Méthodes + - Noeuds + - Reference +translation_of: Web/API/ChildNode/replaceWith +original_slug: Web/API/ChildNode/replaceWith +--- +
{{APIRef("DOM")}}
+La méthode ChildNode.replaceWith() remplace ce ChildNode de la liste des enfants de son parent par un ensemble d'objets {{domxref("Node")}} (noeud) ou {{domxref("DOMString")}} (chaîne de caractères).
+Les objets {{domxref("DOMString")}} sont insérés en tant que noeuds {{domxref("Text")}}.
+ +

Syntaxe

+ +
[Throws, Unscopable]
+void ChildNode.replaceWith((Node ou DOMString)... nodes);
+
+ +

Paramètres

+ +
+
nodes
+
Un ensemble d'objets {{domxref("Node")}} (noeud) ou {{domxref("DOMString")}} (chaîne de caractères) à remplacer.
+
+ +

Exceptions

+ + + +

Exemples

+ +

Utilisation de replaceWith()

+ +
var parent = document.createElement("div");
+var enfant = document.createElement("p");
+parent.appendChild(enfant);
+var span = document.createElement("span");
+
+enfant.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span></div>"
+
+ +

ChildNode.replaceWith() n'est pas accessible

+ +

La méthode replaceWith() n'est pas comprise dans une instruction with. Voir {{jsxref("Symbol.unscopables")}} pour plus d'informations.

+ +
with(node) {
+  replaceWith("foo");
+}
+// ReferenceError: replaceWith n'est pas défini 
+ +

Prothèse d'émulation

+ +

Vous pouvez utiliser une prothèse d'émulation pour la méthode replaceWith() pour Internet Explorer 10 et plus avec le code suivant :

+ +
function ReplaceWith(Ele) {
+  'use-strict'; // For safari, and IE > 10
+  var parent = this.parentNode,
+      i = arguments.length,
+      firstIsNode = +(parent && typeof Ele === 'object');
+  if (!parent) return;
+
+  while (i-- > firstIsNode){
+    if (parent && typeof arguments[i] !== 'object'){
+      arguments[i] = document.createTextNode(arguments[i]);
+    } if (!parent && arguments[i].parentNode){
+      arguments[i].parentNode.removeChild(arguments[i]);
+      continue;
+    }
+    parent.insertBefore(this.previousSibling, arguments[i]);
+  }
+  if (firstIsNode) parent.replaceChild(Ele, this);
+}
+if (!Element.prototype.replaceWith)
+    Element.prototype.replaceWith = ReplaceWith;
+if (!CharacterData.prototype.replaceWith)
+    CharacterData.prototype.replaceWith = ReplaceWith;
+if (!DocumentType.prototype.replaceWith)
+    DocumentType.prototype.replaceWith = ReplaceWith;
+ +

Spécification

+ + + + + + + + + + + + + + +
SpécificationÉtatCommentaire
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Définition initiale.
+ +

Compatibilité des navigateurs

+ + + +

{{Compat("api.ChildNode.replaceWith")}}

+ +

Voir aussi

+ + diff --git a/files/fr/web/api/childnode/replacewith/index.html b/files/fr/web/api/childnode/replacewith/index.html deleted file mode 100644 index 3239ceae59..0000000000 --- a/files/fr/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,117 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: Web/API/ChildNode/replaceWith -tags: - - API - - DOM - - Méthodes - - Noeuds - - Reference -translation_of: Web/API/ChildNode/replaceWith ---- -
{{APIRef("DOM")}}
-La méthode ChildNode.replaceWith() remplace ce ChildNode de la liste des enfants de son parent par un ensemble d'objets {{domxref("Node")}} (noeud) ou {{domxref("DOMString")}} (chaîne de caractères).
-Les objets {{domxref("DOMString")}} sont insérés en tant que noeuds {{domxref("Text")}}.
- -

Syntaxe

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node ou DOMString)... nodes);
-
- -

Paramètres

- -
-
nodes
-
Un ensemble d'objets {{domxref("Node")}} (noeud) ou {{domxref("DOMString")}} (chaîne de caractères) à remplacer.
-
- -

Exceptions

- - - -

Exemples

- -

Utilisation de replaceWith()

- -
var parent = document.createElement("div");
-var enfant = document.createElement("p");
-parent.appendChild(enfant);
-var span = document.createElement("span");
-
-enfant.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() n'est pas accessible

- -

La méthode replaceWith() n'est pas comprise dans une instruction with. Voir {{jsxref("Symbol.unscopables")}} pour plus d'informations.

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith n'est pas défini 
- -

Prothèse d'émulation

- -

Vous pouvez utiliser une prothèse d'émulation pour la méthode replaceWith() pour Internet Explorer 10 et plus avec le code suivant :

- -
function ReplaceWith(Ele) {
-  'use-strict'; // For safari, and IE > 10
-  var parent = this.parentNode,
-      i = arguments.length,
-      firstIsNode = +(parent && typeof Ele === 'object');
-  if (!parent) return;
-
-  while (i-- > firstIsNode){
-    if (parent && typeof arguments[i] !== 'object'){
-      arguments[i] = document.createTextNode(arguments[i]);
-    } if (!parent && arguments[i].parentNode){
-      arguments[i].parentNode.removeChild(arguments[i]);
-      continue;
-    }
-    parent.insertBefore(this.previousSibling, arguments[i]);
-  }
-  if (firstIsNode) parent.replaceChild(Ele, this);
-}
-if (!Element.prototype.replaceWith)
-    Element.prototype.replaceWith = ReplaceWith;
-if (!CharacterData.prototype.replaceWith)
-    CharacterData.prototype.replaceWith = ReplaceWith;
-if (!DocumentType.prototype.replaceWith)
-    DocumentType.prototype.replaceWith = ReplaceWith;
- -

Spécification

- - - - - - - - - - - - - - -
SpécificationÉtatCommentaire
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Définition initiale.
- -

Compatibilité des navigateurs

- - - -

{{Compat("api.ChildNode.replaceWith")}}

- -

Voir aussi

- - diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt index 49b308eb2e..da70e4015f 100644 --- a/files/ja/_redirects.txt +++ b/files/ja/_redirects.txt @@ -3723,6 +3723,7 @@ /ja/docs/Web/API/CanvasRenderingContext2D.removeHitRegion /ja/docs/Web/API/CanvasRenderingContext2D/removeHitRegion /ja/docs/Web/API/Canvas_API/Drawing_graphics_with_canvas /ja/docs/conflicting/Web/API/Canvas_API/Tutorial_3cd5468edc15a1ef1ddc0d2b17e1fa5d /ja/docs/Web/API/ChildNode/remove /ja/docs/orphaned/Web/API/ChildNode/remove +/ja/docs/Web/API/ChildNode/replaceWith /ja/docs/orphaned/Web/API/ChildNode/replaceWith /ja/docs/Web/API/Console.error /ja/docs/Web/API/Console/error /ja/docs/Web/API/Coordinates /ja/docs/Web/API/GeolocationCoordinates /ja/docs/Web/API/DOMCursor.done /ja/docs/Web/API/DOMCursor/done diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json index c036e9e759..8871adaacb 100644 --- a/files/ja/_wikihistory.json +++ b/files/ja/_wikihistory.json @@ -11643,13 +11643,6 @@ "Shirasu" ] }, - "Web/API/ChildNode/replaceWith": { - "modified": "2020-10-17T04:41:48.425Z", - "contributors": [ - "Potappo", - "Shirasu" - ] - }, "Web/API/Client": { "modified": "2020-10-15T22:28:43.389Z", "contributors": [ @@ -52339,6 +52332,13 @@ "chikoski" ] }, + "orphaned/Web/API/ChildNode/replaceWith": { + "modified": "2020-10-17T04:41:48.425Z", + "contributors": [ + "Potappo", + "Shirasu" + ] + }, "orphaned/Web/API/Detecting_device_orientation": { "modified": "2020-10-15T21:21:30.973Z", "contributors": [ diff --git a/files/ja/orphaned/web/api/childnode/replacewith/index.html b/files/ja/orphaned/web/api/childnode/replacewith/index.html new file mode 100644 index 0000000000..28896c90fd --- /dev/null +++ b/files/ja/orphaned/web/api/childnode/replacewith/index.html @@ -0,0 +1,120 @@ +--- +title: ChildNode.replaceWith() +slug: orphaned/Web/API/ChildNode/replaceWith +tags: + - API + - DOM + - Method + - Node + - Reference +translation_of: Web/API/ChildNode/replaceWith +original_slug: Web/API/ChildNode/replaceWith +--- +
{{APIRef("DOM")}}
+ +

ChildNode.replaceWith() は親の子リストの ChildNode を、 {{domxref("Node")}} または {{domxref("DOMString")}} オブジェクトのセットに置換します。 {{domxref("DOMString")}} オブジェクトは {{domxref("Text")}} ノードと等価なノードとして挿入されます。

+ +

構文

+ +
[Throws, Unscopable]
+void ChildNode.replaceWith((Node or DOMString)... nodes);
+
+ +

パラメーター

+ +
+
nodes
+
{{domxref("Node")}} または {{domxref("DOMString")}} オブジェクトのセットで置換します。
+
+ +

例外

+ + + +

+ +

replaceWith() の使用

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span></div>"
+
+ +

ChildNode.replaceWith() はスコーピングに非対応

+ +

replaceWith() メソッドは with 文でのスコーピングに対応していません。詳細は {{jsxref("Symbol.unscopables")}} をご覧ください。

+ +
with(node) {
+  replaceWith("foo");
+}
+// ReferenceError: replaceWith is not defined 
+ +

ポリフィル

+ +

以下のポリフィルで、 Internet Explorer 9 以降でも replaceWith() メソッドが利用できます。

+ +
function ReplaceWithPolyfill() {
+  'use-strict'; // For safari, and IE > 10
+  var parent = this.parentNode, i = arguments.length, currentNode;
+  if (!parent) return;
+  if (!i) // if there are no arguments
+    parent.removeChild(this);
+  while (i--) { // i-- decrements i and returns the value of i before the decrement
+    currentNode = arguments[i];
+    if (typeof currentNode !== 'object'){
+      currentNode = this.ownerDocument.createTextNode(currentNode);
+    } else if (currentNode.parentNode){
+      currentNode.parentNode.removeChild(currentNode);
+    }
+    // the value of "i" below is after the decrement
+    if (!i) // if currentNode is the first argument (currentNode === arguments[0])
+      parent.replaceChild(currentNode, this);
+    else // if currentNode isn't the first
+      parent.insertBefore(currentNode, this.nextSibling);
+  }
+}
+if (!Element.prototype.replaceWith)
+    Element.prototype.replaceWith = ReplaceWithPolyfill;
+if (!CharacterData.prototype.replaceWith)
+    CharacterData.prototype.replaceWith = ReplaceWithPolyfill;
+if (!DocumentType.prototype.replaceWith)
+    DocumentType.prototype.replaceWith = ReplaceWithPolyfill;
+ +

仕様

+ + + + + + + + + + + + + + +
仕様書策定状況コメント
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}初期定義
+ +

ブラウザー実装状況

+ + + +

{{Compat("api.ChildNode.replaceWith")}}

+ +

関連情報

+ + diff --git a/files/ja/web/api/childnode/replacewith/index.html b/files/ja/web/api/childnode/replacewith/index.html deleted file mode 100644 index 1f5874de65..0000000000 --- a/files/ja/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,119 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: Web/API/ChildNode/replaceWith -tags: - - API - - DOM - - Method - - Node - - Reference -translation_of: Web/API/ChildNode/replaceWith ---- -
{{APIRef("DOM")}}
- -

ChildNode.replaceWith() は親の子リストの ChildNode を、 {{domxref("Node")}} または {{domxref("DOMString")}} オブジェクトのセットに置換します。 {{domxref("DOMString")}} オブジェクトは {{domxref("Text")}} ノードと等価なノードとして挿入されます。

- -

構文

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node or DOMString)... nodes);
-
- -

パラメーター

- -
-
nodes
-
{{domxref("Node")}} または {{domxref("DOMString")}} オブジェクトのセットで置換します。
-
- -

例外

- - - -

- -

replaceWith() の使用

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() はスコーピングに非対応

- -

replaceWith() メソッドは with 文でのスコーピングに対応していません。詳細は {{jsxref("Symbol.unscopables")}} をご覧ください。

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith is not defined 
- -

ポリフィル

- -

以下のポリフィルで、 Internet Explorer 9 以降でも replaceWith() メソッドが利用できます。

- -
function ReplaceWithPolyfill() {
-  'use-strict'; // For safari, and IE > 10
-  var parent = this.parentNode, i = arguments.length, currentNode;
-  if (!parent) return;
-  if (!i) // if there are no arguments
-    parent.removeChild(this);
-  while (i--) { // i-- decrements i and returns the value of i before the decrement
-    currentNode = arguments[i];
-    if (typeof currentNode !== 'object'){
-      currentNode = this.ownerDocument.createTextNode(currentNode);
-    } else if (currentNode.parentNode){
-      currentNode.parentNode.removeChild(currentNode);
-    }
-    // the value of "i" below is after the decrement
-    if (!i) // if currentNode is the first argument (currentNode === arguments[0])
-      parent.replaceChild(currentNode, this);
-    else // if currentNode isn't the first
-      parent.insertBefore(currentNode, this.nextSibling);
-  }
-}
-if (!Element.prototype.replaceWith)
-    Element.prototype.replaceWith = ReplaceWithPolyfill;
-if (!CharacterData.prototype.replaceWith)
-    CharacterData.prototype.replaceWith = ReplaceWithPolyfill;
-if (!DocumentType.prototype.replaceWith)
-    DocumentType.prototype.replaceWith = ReplaceWithPolyfill;
- -

仕様

- - - - - - - - - - - - - - -
仕様書策定状況コメント
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}初期定義
- -

ブラウザー実装状況

- - - -

{{Compat("api.ChildNode.replaceWith")}}

- -

関連情報

- - diff --git a/files/ru/_redirects.txt b/files/ru/_redirects.txt index 05cc2dc6dc..e8606a2a38 100644 --- a/files/ru/_redirects.txt +++ b/files/ru/_redirects.txt @@ -384,6 +384,7 @@ /ru/docs/Web/API/Canvas_API/Tutorial/Рисование_фигур /ru/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes /ru/docs/Web/API/Canvas_API/Рисование_графики_с_помощью_Canvas /ru/docs/Web/API/Canvas_API/Tutorial /ru/docs/Web/API/ChildNode/remove /ru/docs/orphaned/Web/API/ChildNode/remove +/ru/docs/Web/API/ChildNode/replaceWith /ru/docs/orphaned/Web/API/ChildNode/replaceWith /ru/docs/Web/API/Coordinates /ru/docs/Web/API/GeolocationCoordinates /ru/docs/Web/API/Document.querySelectorAll /ru/docs/Web/API/Document/querySelectorAll /ru/docs/Web/API/Document/async /ru/docs/Web/API/XMLDocument/async diff --git a/files/ru/_wikihistory.json b/files/ru/_wikihistory.json index 8bb44773ad..25562288d5 100644 --- a/files/ru/_wikihistory.json +++ b/files/ru/_wikihistory.json @@ -6485,12 +6485,6 @@ "pantherCZ" ] }, - "Web/API/ChildNode/replaceWith": { - "modified": "2020-12-02T15:53:32.691Z", - "contributors": [ - "kosarev_va" - ] - }, "Web/API/Clients": { "modified": "2019-03-23T22:15:29.932Z", "contributors": [ @@ -25536,6 +25530,12 @@ "In4in" ] }, + "orphaned/Web/API/ChildNode/replaceWith": { + "modified": "2020-12-02T15:53:32.691Z", + "contributors": [ + "kosarev_va" + ] + }, "orphaned/Web/API/Document_Object_Model/Events": { "modified": "2019-03-18T21:18:44.250Z", "contributors": [ diff --git a/files/ru/orphaned/web/api/childnode/replacewith/index.html b/files/ru/orphaned/web/api/childnode/replacewith/index.html new file mode 100644 index 0000000000..0ee9091325 --- /dev/null +++ b/files/ru/orphaned/web/api/childnode/replacewith/index.html @@ -0,0 +1,114 @@ +--- +title: ChildNode.replaceWith() +slug: orphaned/Web/API/ChildNode/replaceWith +translation_of: Web/API/ChildNode/replaceWith +original_slug: Web/API/ChildNode/replaceWith +--- +
{{APIRef("DOM")}}
+ +

Метод ChildNode.replaceWith() заменяет ChildNode в списке детей их родителя множеством {{domxref("Node")}} или {{domxref("DOMString")}} объектов. {{domxref("DOMString")}} объекты вставляются как эквивалент нод {{domxref("Text")}}.

+ +

Синтаксис

+ +
[Throws, Unscopable]
+void ChildNode.replaceWith((Node or DOMString)... nodes);
+
+ +

Параметры

+ +
+
nodes
+
Множество заменяемых {{domxref("Node")}} или {{domxref("DOMString")}} объектов.
+
+ +

Исключения

+ + + +

Примеры

+ +

Использование replaceWith()

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span></div>"
+
+ +

ChildNode.replaceWith() не выполним

+ +

Метод replaceWith() не входит в область видимости оператора with. Смотрите {{jsxref("Symbol.unscopables")}} для дополнительной информации.

+ +
with(node) {
+  replaceWith("foo");
+}
+// ReferenceError: replaceWith is not defined 
+ +

Полифил

+ +

Вы можете заполнить метод replaceWith() в Internet Explorer 10+ и выше следующим кодом:

+ +
function ReplaceWithPolyfill() {
+  'use-strict'; // For safari, and IE > 10
+  var parent = this.parentNode, i = arguments.length, currentNode;
+  if (!parent) return;
+  if (!i) // if there are no arguments
+    parent.removeChild(this);
+  while (i--) { // i-- decrements i and returns the value of i before the decrement
+    currentNode = arguments[i];
+    if (typeof currentNode !== 'object'){
+      currentNode = this.ownerDocument.createTextNode(currentNode);
+    } else if (currentNode.parentNode){
+      currentNode.parentNode.removeChild(currentNode);
+    }
+    // the value of "i" below is after the decrement
+    if (!i) // if currentNode is the first argument (currentNode === arguments[0])
+      parent.replaceChild(currentNode, this);
+    else // if currentNode isn't the first
+      parent.insertBefore(currentNode, this.nextSibling);
+  }
+}
+if (!Element.prototype.replaceWith)
+    Element.prototype.replaceWith = ReplaceWithPolyfill;
+if (!CharacterData.prototype.replaceWith)
+    CharacterData.prototype.replaceWith = ReplaceWithPolyfill;
+if (!DocumentType.prototype.replaceWith)
+    DocumentType.prototype.replaceWith = ReplaceWithPolyfill;
+ +

Спецификация

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

Совместимость с браузерами

+ + + +

{{Compat("api.ChildNode.replaceWith")}}

+ +

Смотрите также

+ + diff --git a/files/ru/web/api/childnode/replacewith/index.html b/files/ru/web/api/childnode/replacewith/index.html deleted file mode 100644 index b4563085ff..0000000000 --- a/files/ru/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,113 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: Web/API/ChildNode/replaceWith -translation_of: Web/API/ChildNode/replaceWith ---- -
{{APIRef("DOM")}}
- -

Метод ChildNode.replaceWith() заменяет ChildNode в списке детей их родителя множеством {{domxref("Node")}} или {{domxref("DOMString")}} объектов. {{domxref("DOMString")}} объекты вставляются как эквивалент нод {{domxref("Text")}}.

- -

Синтаксис

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node or DOMString)... nodes);
-
- -

Параметры

- -
-
nodes
-
Множество заменяемых {{domxref("Node")}} или {{domxref("DOMString")}} объектов.
-
- -

Исключения

- - - -

Примеры

- -

Использование replaceWith()

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() не выполним

- -

Метод replaceWith() не входит в область видимости оператора with. Смотрите {{jsxref("Symbol.unscopables")}} для дополнительной информации.

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith is not defined 
- -

Полифил

- -

Вы можете заполнить метод replaceWith() в Internet Explorer 10+ и выше следующим кодом:

- -
function ReplaceWithPolyfill() {
-  'use-strict'; // For safari, and IE > 10
-  var parent = this.parentNode, i = arguments.length, currentNode;
-  if (!parent) return;
-  if (!i) // if there are no arguments
-    parent.removeChild(this);
-  while (i--) { // i-- decrements i and returns the value of i before the decrement
-    currentNode = arguments[i];
-    if (typeof currentNode !== 'object'){
-      currentNode = this.ownerDocument.createTextNode(currentNode);
-    } else if (currentNode.parentNode){
-      currentNode.parentNode.removeChild(currentNode);
-    }
-    // the value of "i" below is after the decrement
-    if (!i) // if currentNode is the first argument (currentNode === arguments[0])
-      parent.replaceChild(currentNode, this);
-    else // if currentNode isn't the first
-      parent.insertBefore(currentNode, this.nextSibling);
-  }
-}
-if (!Element.prototype.replaceWith)
-    Element.prototype.replaceWith = ReplaceWithPolyfill;
-if (!CharacterData.prototype.replaceWith)
-    CharacterData.prototype.replaceWith = ReplaceWithPolyfill;
-if (!DocumentType.prototype.replaceWith)
-    DocumentType.prototype.replaceWith = ReplaceWithPolyfill;
- -

Спецификация

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

Совместимость с браузерами

- - - -

{{Compat("api.ChildNode.replaceWith")}}

- -

Смотрите также

- - diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index c19912bb2b..32e696949c 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1468,6 +1468,7 @@ /zh-CN/docs/Web/API/ChildNode.nextElementSibling /zh-CN/docs/Web/API/Element/nextElementSibling /zh-CN/docs/Web/API/ChildNode.remove /zh-CN/docs/orphaned/Web/API/ChildNode/remove /zh-CN/docs/Web/API/ChildNode/remove /zh-CN/docs/orphaned/Web/API/ChildNode/remove +/zh-CN/docs/Web/API/ChildNode/replaceWith /zh-CN/docs/orphaned/Web/API/ChildNode/replaceWith /zh-CN/docs/Web/API/Childnode.previousElementSibling /zh-CN/docs/Web/API/Element/previousElementSibling /zh-CN/docs/Web/API/Coordinates /zh-CN/docs/Web/API/GeolocationCoordinates /zh-CN/docs/Web/API/Coordinates/latitude /zh-CN/docs/Web/API/GeolocationCoordinates/latitude diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index 84cda02220..46ebaa388b 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -9761,15 +9761,6 @@ "caoweiju" ] }, - "Web/API/ChildNode/replaceWith": { - "modified": "2020-10-15T21:56:06.625Z", - "contributors": [ - "ecnelises", - "SphinxKnight", - "wzx", - "VictorDu" - ] - }, "Web/API/Client": { "modified": "2019-03-23T22:16:43.346Z", "contributors": [ @@ -50227,6 +50218,15 @@ "Darrel.Hsu" ] }, + "orphaned/Web/API/ChildNode/replaceWith": { + "modified": "2020-10-15T21:56:06.625Z", + "contributors": [ + "ecnelises", + "SphinxKnight", + "wzx", + "VictorDu" + ] + }, "orphaned/Web/API/Detecting_device_orientation": { "modified": "2020-10-15T21:21:28.912Z", "contributors": [ diff --git a/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html b/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html new file mode 100644 index 0000000000..9f3ef5bd88 --- /dev/null +++ b/files/zh-cn/orphaned/web/api/childnode/replacewith/index.html @@ -0,0 +1,112 @@ +--- +title: ChildNode.replaceWith() +slug: orphaned/Web/API/ChildNode/replaceWith +tags: + - DOM + - Node +translation_of: Web/API/ChildNode/replaceWith +original_slug: Web/API/ChildNode/replaceWith +--- +
{{APIRef("DOM")}} {{SeeCompatTable}}
+ +

ChildNode.replaceWith() 的方法用一套 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象,替换了该节点父节点下的子节点 。{{domxref("DOMString")}} 对象被当做等效的{{domxref("Text")}} 节点插入。

+ +

语法

+ +
[Throws, Unscopable]
+void ChildNode.replaceWith((Node or DOMString)... nodes);
+
+ +

参数

+ +
+
节点
+
一系列用来替换的{{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。
+
+ +

例外

+ + + +

案例

+ +

Using replaceWith()

+ +
var parent = document.createElement("div");
+var child = document.createElement("p");
+parent.appendChild(child);
+var span = document.createElement("span");
+
+child.replaceWith(span);
+
+console.log(parent.outerHTML);
+// "<div><span></span></div>"
+
+ +

ChildNode.replaceWith() is unscopable

+ +

replaceWith()的方法并没有作用于with语句. 参考 {{jsxref("Symbol.unscopables")}} 获取更多信息.

+ +
with(node) {
+  replaceWith("foo");
+}
+// ReferenceError: replaceWith is not defined 
+ +

Polyfill

+ +

你可以在IE9及更高级的浏览器中使用下面的代码向上兼容replaceWith()的方法:

+ +
(function (arr) {
+  arr.forEach(function (item) {
+    if (item.hasOwnProperty('replaceWith')) {
+      return;
+    }
+    Object.defineProperty(item, 'replaceWith', {
+      configurable: true,
+      enumerable: true,
+      writable: true,
+      value: function replaceWith() {
+        var argArr = Array.prototype.slice.call(arguments),
+          docFrag = document.createDocumentFragment();
+
+        argArr.forEach(function (argItem) {
+          var isNode = argItem instanceof Node;
+          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
+        });
+
+        this.parentNode.replaceChild(docFrag, this);
+      }
+    });
+  });
+})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
+ +

规范

+ + + + + + + + + + + + + + +
规范状态注释
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

浏览器兼容性

+ +

{{Compat("api.ChildNode.replaceWith")}}

+ +

参阅

+ + diff --git a/files/zh-cn/web/api/childnode/replacewith/index.html b/files/zh-cn/web/api/childnode/replacewith/index.html deleted file mode 100644 index 37e2d93a5a..0000000000 --- a/files/zh-cn/web/api/childnode/replacewith/index.html +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: ChildNode.replaceWith() -slug: Web/API/ChildNode/replaceWith -tags: - - DOM - - Node -translation_of: Web/API/ChildNode/replaceWith ---- -
{{APIRef("DOM")}} {{SeeCompatTable}}
- -

ChildNode.replaceWith() 的方法用一套 {{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象,替换了该节点父节点下的子节点 。{{domxref("DOMString")}} 对象被当做等效的{{domxref("Text")}} 节点插入。

- -

语法

- -
[Throws, Unscopable]
-void ChildNode.replaceWith((Node or DOMString)... nodes);
-
- -

参数

- -
-
节点
-
一系列用来替换的{{domxref("Node")}} 对象或者 {{domxref("DOMString")}} 对象。
-
- -

例外

- - - -

案例

- -

Using replaceWith()

- -
var parent = document.createElement("div");
-var child = document.createElement("p");
-parent.appendChild(child);
-var span = document.createElement("span");
-
-child.replaceWith(span);
-
-console.log(parent.outerHTML);
-// "<div><span></span></div>"
-
- -

ChildNode.replaceWith() is unscopable

- -

replaceWith()的方法并没有作用于with语句. 参考 {{jsxref("Symbol.unscopables")}} 获取更多信息.

- -
with(node) {
-  replaceWith("foo");
-}
-// ReferenceError: replaceWith is not defined 
- -

Polyfill

- -

你可以在IE9及更高级的浏览器中使用下面的代码向上兼容replaceWith()的方法:

- -
(function (arr) {
-  arr.forEach(function (item) {
-    if (item.hasOwnProperty('replaceWith')) {
-      return;
-    }
-    Object.defineProperty(item, 'replaceWith', {
-      configurable: true,
-      enumerable: true,
-      writable: true,
-      value: function replaceWith() {
-        var argArr = Array.prototype.slice.call(arguments),
-          docFrag = document.createDocumentFragment();
-
-        argArr.forEach(function (argItem) {
-          var isNode = argItem instanceof Node;
-          docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
-        });
-
-        this.parentNode.replaceChild(docFrag, this);
-      }
-    });
-  });
-})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
- -

规范

- - - - - - - - - - - - - - -
规范状态注释
{{SpecName('DOM WHATWG', '#dom-childnode-replacewith', 'ChildNode.replacewith()')}}{{Spec2('DOM WHATWG')}}Initial definition.
- -

浏览器兼容性

- -

{{Compat("api.ChildNode.replaceWith")}}

- -

参阅

- - -- cgit v1.2.3-54-g00ecf