Questions tagged [dom]

35 questions
48
votes
4 answers

What's so bad about the DOM?

I keep hearing people (Crockford in particular) saying the DOM is a terrible API, but not really justifying this statement. Apart from cross-browser inconsistencies, what are some reasons why the DOM is considered to be so bad?
wheresrhys
  • 664
  • 1
  • 5
  • 7
30
votes
1 answer

What is the difference between web components and custom elements?

"Web Components" and "Custom elements" are often mixed up, and web searches for the title of this question don't yet produce much clarity. Let's fix that.
Dan Dascalescu
  • 896
  • 1
  • 7
  • 16
25
votes
1 answer

Is vanilla JS still considered a library?

I very recently found out that VanillaJS (document?) is a library that's just bundled with 99% browsers and isn't exactly native JavaScript (shock of my life). While writing a lib of my own I normally avoid all helpful things, mostly libs. Now I…
DividedByZero
  • 411
  • 1
  • 4
  • 8
25
votes
1 answer

A few clarifications about the DOM

I have been trying to understand the DOM, and although I have a fair idea of what it is, there are certain ideas I just cannot pin down. I will list down what I think the DOM is and my questions will be inline. The DOM is a fully object-oriented…
user1720897
  • 599
  • 1
  • 5
  • 12
12
votes
1 answer

Google Blink (new WebKit fork): Meaning of "Moving DOM into Javascript"?

From the Blink Blog: Finally we’d like to explore even larger ideas like moving the entire Document Object Model (DOM) into JavaScript. What does this mean? Does it mean WebKit's DOM is currently not coded in JavaScript but in some other language?…
BSalita
  • 323
  • 2
  • 6
10
votes
3 answers

Should I reduce event listeners by making functions more complex?

An example would be if you had multiple inputs, each of which effect a completely different process, (perhaps one changes a div's width, while another sends ajax request for predictive search), would you bind a single event use a switch statement to…
user232573
8
votes
3 answers

How do you 'merge' several JS files into one?

New Web Dev here. Recently I got into DOM manipulation with JS, everything was sweet with one-page websites, but then I tried with projects with many html files and that's when I got confused. It's a static website, each page has different elements…
JosueMagnus12
  • 99
  • 1
  • 1
  • 4
7
votes
3 answers

In DOM, why is childNodes defined in the Node interface if only some node types can have childNodes?

In DOM, why is childNodes defined in the Node interface if only some node types such as Element, Document and DocumentFragement, can have childNodes? Is this considered a good design? In what cases this is admissible? I mean, isn't this like…
Alfredo Osorio
  • 904
  • 1
  • 11
  • 18
6
votes
3 answers

Should jQuery DOM manipulation be avoided in favor of JavaScript template engines?

From what I can tell, most developers will use heavy jQuery DOM manipulation tactics to deliver their updated AJAX views. Once things get out of hand, they may consider refactoring using template engines such as Mustache.js. Is this a valid…
Jason Rikard
  • 163
  • 1
  • 5
5
votes
1 answer

Best way to verify that a user has completed a task on another website.

We are developing a website for students on which they first have to fulfill specific tasks in order to use our service. The problem is, that those tasks are on another website, which has nothing to do with ours and is currently placed in an iframe…
D_Burg
  • 51
  • 2
5
votes
1 answer

How is the DOM language independent?

Quoting from Wikipedia The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. and from wc3 In order to provide a precise,…
Songo
  • 6,548
  • 4
  • 48
  • 89
4
votes
1 answer

Need a deeper understanding of how a Virtual DOM is different from a real DOM

As all articles say the Virtual DOM is lightweight and allows us to update only those nodes that has to be updated, unlike the real DOM that updates the whole nodes structure. So the first question: how is Virtual DOM lightweight? Since it can't…
devdevdove
  • 147
  • 1
  • 3
4
votes
2 answers

Why is the Document Object Model the view?

I was told by a Javascript programmer not to do DOM manipulation in model code. I also remember hearing a snazzy tune for a JS framework (I forget which one): "Get your models out of the DOM". This is confusing to me. The DOM is the Document Object…
Paul Draper
  • 5,972
  • 3
  • 22
  • 37
4
votes
3 answers

Javascript Use of Window Object through alternate means

Disregard your usual paradigms for a mere moment here.... I've seen a few sites who have used the following logic: a=[]; b=a["sort"]; c=(b)(); c["alert"](1); // intended output: Alert displaying "1"... supposedly to access (I'm guessing here) the…
4
votes
1 answer

xpath vs DOM API

I just came up on xpath recently while writing a greasemonkey script and immediately fell in love. I haven't done any benchmarking yet (coming soon), but according to a couple sources that I read, xpath is faster than using the DOM API. After…
Demian Brecht
  • 17,555
  • 1
  • 47
  • 81
1
2 3