You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
DOMDOMタイムス、今日はDOMの内部実装の話。話を単純にするため、V8の実装を念頭において進めていくよ。 ふだんJavaScriptで操作しているDOMのオブジェクトは、ブラウザ内部で管理されているDOMのオブジェクトとは別のものだよという話。 これだけ聞くと当たり前かもしれないけど、周辺をふかぼりして考えてみるとけっこう面白かったわけです👶 DOMの実体、そしてDOM wrapper さっそくだけどDOMの実体はブラウザ内部、例えばchromiumならC++の世界に存在していることに思いを馳せてほしいのです。 考えてみればchromiumの場合、ページを構築するのはBlinkというレンダリングエンジンなわけで、C++で実装されたBlinkがHTMLやらCSSやら場合によってはscriptまで含めた材料からDOMを構成してくれています。 BlinkがC++の世界、というかブラウザ内部
Offers を運営している株式会社 overflow の あほむ でございます。 本記事は Chrome Platform Status からなんとなく Proposed/In Development etc なステータスのフィーチャーを取り上げて、そのプロポーザルを眺めてみるシリーズです。前回は form-sizing field-sizing CSS property でした。 SPA 的な画面遷移を性能計測したい 今回は Soft Navigations Performance Entry を眺めてみます。本当に眺めるだけで深入りしないので概要のみのライトな記事とご認識ください。 SPA 的な画面遷移とはつまり History.pushState や History.replaceState を用いた JavaScript 駆動なナビゲーションを指します。このような遷移を指してここ
MutationObserver の使い方 まずは MutationObserver の使い方を簡単に紹介します。次のサンプルは span 要素のテキストの変更を検知して、変更前のテキストと変更後のテキストをコンソールに出力します。 // MutationObserver オブジェクトを生成 const observer = new MutationObserver((mutations) => { const rec = mutations[0]; // MutationRecord オブジェクト const before = rec.removedNodes[0].data; // 変更前のテキスト const after = rec.addedNodes[0].data; // 変更後のテキスト console.log('「' + before + '」が「' + after + '
We’re pleased to announce that support for the declarative shadow DOM API has been added and enabled by default in Safari Technology Preview 162. To recap, shadow DOM is a part of Web Components, a set of specifications that were initially proposed by Google to enable the creation of reusable widgets and components on the web. Since then these specifications have been integrated into the DOM and H
New Project 🐷 Porkybank: Track your daily budgetLearn to Code Like a DeveloperCodeamigo is an AI powered coding assistant that helps you learn to code like a developer. Today's developers didn't learn binary before learning Python, why should you learn how to code without the most modern tools?PSA: I will no longer be maintaining Codeamigo. I am working on a new project called Porkybank. It's a t
This release switches our CSS selector engine from nwsapi to @asamuzakjp/dom-selector. The new engine is more actively maintained, and supports many new selectors: see the package's documentation for the full list. It also works better with shadow trees. There is a potential of a performance regression due to this change. In our stress test benchmark, which runs most of these 273 selectors against
I've found a bug in Firefox sanitizer that can be exploited if the result of sanitizeToString is used in a sink that doesn't parse the HTML using fragment parsing algorithm (examples being: iframe.srcdoc, data:text/html,markup etc.) Proof of concept Here's the proof-of-concept: <iframe id=ifr></iframe> <script> const bypass = `<svg><font color><title><u rel="</title><img src onerror=alert(document
はじめに Javascriptを学ぶ上で欠かせないDOMについて、基礎的な部分を固めたいのでまとめました。 学習サイトやなんやらでJavaScriptの文法的な基礎を学んだ後、次は?みたいな人(わたし)が多いと思います。 そんな方のステップアップに繋がるのがDOMなのかなーと思ってるので、DOM操作に慣れていければいいなと。 目次 DOMとは DOMで何ができるようになるのか 要素の取得をする 要素取得のメソッド 要素にアクセスして変更を加える クラスを操作する DOMとは 「Document Object Model」の略です。 HTMLはHTML文章と呼ばれることもあり、文章=Document。 つまりHTML(XMLなども)オブジェクトとして扱い、それを操作するためのモデルです。 その操作をすることを DOM API や DOM と呼びます。 DOMで何ができるようになるのか Jav
Listening to and responding to events is a foundational skill for building software for the web. The Document Object Model, or DOM for short, has a powerful built-in event system. And yet, many of us have a pretty basic understanding of the DOM event system and only scratch the surface of the available power. This lack of understanding leads to bugs in our applications and writing lots of code to
Content Scripts を使う。 ボタン押下とかショートカットキーとかそういうイベントで操作したいなら、 Background から content script のイベントハンドラを呼ぶことになる。 以下、 選択したテキストを<samp>要素でラップする例。 chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { if (request.text == "code-block") { const selection = window.getSelection().toString().replace(/\n/g, "<br/>"); const insertContent = `<samp>${selection}</samp>`; document.execCommand("
If you work with form submissions, you might have noticed that form values containing newlines are normalized to CRLF, no matter whether the DOM value had LF or CR instead: <form action="./post" method="post" enctype="application/x-www-form-urlencoded"> <input type="hidden" name="hidden" value="a
b
c
d" /> <input type="submit" /> </form> <script> // Checking that the DOM has t
text 「text」にはHTMLやXMLとして挿入することができる文字列を指定します。 下記はinsertAdjacentHTMLのpositionに各値を指定して実行した際の挿入場所を表したものです。コメントの位置に「text」に記述したHTML要素が挿入されます。 <!-- beforebegin --> <div> <!-- afterbegin --> intotheprogram <!-- beforeend --> </div> <!-- afterend --> insertAdjacentHTMLでHTML要素を追加する では、実際に各「position」にHTML要素を追加してみます。下記のHTML要素に対して、段落のタグを追加します。 <div id="box"> <h1>Title</h1> </div> 各「position」を指定した際の実行結果も記載しておりま
Assume you have a valid HTML element in DOM. I assumed the following snippets to be the same. let id = "037e3778-e157-4715-bff5-e466230fe7a3" const byId = document.getElementById(id) console.log(byId) // works const bySelectorConcat = document.querySelector("#" + id) console.log(bySelectorConcat) // Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#037e3778-e157-4715-bff5-e
TreeWalker オブジェクトは、文書のサブツリーのノードおよびその位置を表します。 TreeWalker は document オブジェクトの Document.createTreeWalker() (en-US) メソッドを使用して作成可能です。 このインターフェイスが継承するプロパティはありません。 TreeWalker.root 読取専用 TreeWalker を作成したときに指定したルートノードを表す Node を返します。 TreeWalker.whatToShow (en-US) 読取専用 提供しなければならない Node の型を表す定数で構成されるビットマスクである unsigned long を返します。一致しないノードはスキップされますが、その子は関連があれば含まれます。使用できる値は以下のとおりです。 定数 数値 説明
◆ mousemove の代わりに pointermove を使うと PointerEvent を受け取れる ◆ PointerEvent の getCoalescedEvents() を使ってイベントを取得すると 高負荷時に mousemove で取れなかった座標のイベントも取得できる ◆ getPredictedEvents() を使うとほんの少し未来の座標を予測できる 知名度が低い?せいで探すのに苦戦したマウスの移動の履歴を取得する必要がありました 普通にやると mousemove イベントにリスナを設定してイベントが起きたときの座標を取得します ただ この方法って負荷が高いときには飛び飛びになったりで あまり正確じゃないんですよね 以前それをうまくやる方法を使ったことがあったはず なのですが何というメソッドを使ったかを全然覚えてなくて苦戦しました ググればすぐに出ると思ったのに そ
Probably the fastest virtual dom library in the world! IMPORTANT: blockdom is just a proof of concept and a place to experiment some ideas. This is not intended to be used in a real application, no real support will be given! However, it is designed to be the rendering engine of the Owl framework! blockdom is a very fast virtual dom library. Its main selling point is that it does not represent DOM
SetupFirst, let’s make sure that your development environment is ready. If you don’t have Node.js installed, install it from here. You’ll need Node.js version 18 or higher.You’ll be using your own text editor and terminal app for this tutorial.If you are on Windows, we recommend downloading Git for Windows and use Git Bash that comes with it, which supports the UNIX-specific commands in this tutor
An agnostic, reactive & minimalist (3kb) JavaScript UI library with direct access to native DOM. Instead of pulling you into a library-specific magical world, CalDOM let you fully access the DOM directly while keeping the reactivity 💥. So you could take full advantage of native APIs & mix it with other libraries to gain superior performance & flexibility in the development process. A 2-in-1 virtu
Latest topics > Virtual DOMでなく生のDocumentFragmentを与えてDOMを差分更新したいって話 宣伝。日経LinuxにてLinuxの基礎?を紹介する漫画「シス管系女子」を連載させていただいています。 以下の特設サイトにて、単行本まんがでわかるLinux シス管系女子の試し読みが可能! « 安眠を手に入れるために工作と裁縫した Main 「もっと考えろよ」「想像力なさすぎだろ」みたいな言い方を僕はしたくないなっていう話 » Virtual DOMでなく生のDocumentFragmentを与えてDOMを差分更新したいって話 - Mar 09, 2020 この記事はQiitaとのクロスポストです。 概要 FirefoxのアドオンやChromeの拡張機能向けに、名前空間をまたいでDOMに変更を差分適用したい場面で使える、Virtual DOMでないReal
【DOM操作(前編)】JavaScriptのaddEventListenerについて、「・・したら」をまとめてみたJavaScriptes6初学者向けdom操作 今回はJavaScriptのDOM操作の 「addEventListener」 についてまとめてみました。 DOM操作初心者の方のご参考になれば嬉しいです。 基本的なDOM操作(addEventListener)の流れ ①まずは要素の取得。 ②取得した要素にaddEventListenerで処理を追加する → このaddEventListenerの第一引数と第二引数が重要です ③処理の"きっかけ(第一引数)"を記述 →⭐️今回のメインはこの③になります。 ④"処理を関数内(第二引数)"に記述 →→※こちらは次回(後編)で紹介します... ※慣れている方は①②は飛ばしてOK ①要素を取得する DOM操作をする上でまずはHTMLに記述
こんにちは、kz_moritaです。 最近はVue.js / Nuxt.js あたりで Web フロントを書いたりしています。 今回は、ページの最上部からある特定のDOMの位置座標を取得するのにちょっとつまづいたため、そのことについてまとめておきます。 試した方法 以下の二種類の方法を試しました。 HTMLElement.offsetTop Element.getBoundingClientRect().top + window.pageYOffset 結論から言うと、ページの最上部からの位置を取得する仕様は2つ目の方法で実現することができました。 HTMLElement.offetTop HTMLElement.offsetTopの仕様は以下のサイトに詳しく書いています。 https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/
import {DOMParser, parseHTML} from 'linkedom'; // Standard way: text/html, text/xml, image/svg+xml, etc... // const document = (new DOMParser).parseFromString(html, 'text/html'); // Simplified way for HTML const { // note, these are *not* globals window, document, customElements, HTMLElement, Event, CustomEvent // other exports .. } = parseHTML(` <!doctype html> <html lang="en"> <head> <title>Hell
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く