Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
Recorriendo todos los nodejs en el rango seleccionado

¿Cómo puede recuperar todos los nodejs dentro del rango seleccionado en javascript, por ejemplo, si resalto los siguientes nodejs en esta publicación de stackoverflow? ¿Es posible crear un iterador simple dado el node base y de extensión que recorre el DOMTree entre los dos?{*** } ingrese la descripción de la imagen aquí

Intenté usar Range y TreeWalker, pero no se me ocurrió nada. Solo obtengo un recuento de rango de 1.

almost 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Puede obtener una copia de los nodejs seleccionados recorriendo el rango seleccionado y clonando el contenido de la selección del rango. Recopile todos los nodejs clonados en un objeto DocumentFragment .

Luego cree un TreeWalker con el objeto DocumentFragment que tiene los elementos recopilados y empuje cada node a una nueva matriz.

La matriz resultante será una lista de todos los nodejs de la selección.


Ejecute el ejemplo a continuación y verifique la consola de su navegador después de seleccionar el texto y hacer clic en el botón Obtener nodejs seleccionados .

 const button = document.getElementById('get-nodes');

function getSelectedNodes() {
 const selection = document.getSelection();
 const fragment = document.createDocumentFragment();
 const nodeList = [];

 for (let i = 0; i < selection.rangeCount; i++) {
 fragment.append(selection.getRangeAt(i).cloneContents());
 }

 const walker = document.createTreeWalker(fragment);
 let currentNode = walker.currentNode;

 while(currentNode) {
 nodeList.push(currentNode);
 currentNode = walker.nextNode();
 }

 return nodeList;
}

button.addEventListener('click', () => {
 const nodeList = getSelectedNodes();
 console.log(nodeList);
});
 <button id="get-nodes">Get selected nodes</button>

<div class="s-prose js-post-body" itemprop="text">
 <p>I'm running spring cloud dataflow server in a container and was able to configure app logs to a specific folder that is brought outside of the container. However, I can't figure out how to store dataflow server logs themselves in a file.</p>
 <p>According to this:
 <a href="https://docs.spring.io/spring-cloud-dataflow/docs/2.7.2/reference/htmlsingle/#configuration-local-logging" rel="nofollow noreferrer">https://docs.spring.io/spring-cloud-dataflow/docs/2.7.2/reference/htmlsingle/#configuration-local-logging</a></p>
 <p>It should be plain and simple, just set LOG_PATH and that's pretty much it. But that does nothing. And when I look at logback-spring.xml in the jar file, I can see that:</p>
 <pre class="default s-code-block"><code class="hljs language-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">root</span> <span class="hljs-attr">level</span>=<span class="hljs-string">"INFO"</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-name">appender-ref</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"STDOUT"</span>/&gt;</span>
 <span class="hljs-tag">&lt;/<span class="hljs-name">root</span>&gt;</span>
 </code></pre>
 <p>Which in my understanding is the reason why the logs don't go into the file, they just go to the console.</p>
 <p>Is there a way to override the appender-ref attribute in the logback-spring.xml with an environnment variable, or how can I get the dataflow server logs in a file?</p>
</div>

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda