Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for node document or always set it explicitly #212

Closed
ArkadiuszMichalski opened this issue Apr 9, 2016 · 9 comments
Closed

Comments

@ArkadiuszMichalski
Copy link
Contributor

https://dom.spec.whatwg.org/#concept-node-document
"Each node has an associated node document, set upon creation, that is a document."
So every time when we create new node we must set node document for this node. But in some case you don't do this:

https://dom.spec.whatwg.org/#dom-element-insertadjacenttext

  1. Let text be a new Text object whose data is data. < btw, you can change this to "new Text node" (and linked /Text/ and /node/) like in any other case.
    Of course finally this new Text node will have correct node document because in step 2. we run "insert adjacent" which use "adopt" but it does not fit to definition node document.

Other similar cases:
https://dom.spec.whatwg.org/#dom-node-textcontent << element's setter
https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument << this is more interesting because you also use new element (html/head/title/body) but it's to general, how you create them (using "create an element" algorithm)? After changing definition around Element (due to custom elements) I don't see that default value for namespace and namespace prefix is null. This was removed: "When an element is created, its local name is always given. Unless explicitly given when an element is created, its namespace and namespace prefix are null."

Maybe define default value for node document to global object’s associated document for other node than document and for document use himself (or something else more uniwersal) and change it explicitly in other algorithms only when necessary? If no then node document should always be set explicitly when node is created in some cases, even if for the moment will be automatically changed by other step in algorithm because that is the definition of node document, but it's a little uncomfortable.

annevk added a commit that referenced this issue Apr 16, 2016
Fixes #224 and part of #212. Also fix part of #209 by stating these
algorithms can rethrow exceptions.
@annevk
Copy link
Member

annevk commented Apr 16, 2016

Hmm yeah, we should probably use https://dom.spec.whatwg.org/#concept-create-element to define createHTMLDocument(). @domenic?

@annevk
Copy link
Member

annevk commented Apr 16, 2016

(I don't think a default node document works well as it's typically just the node document of the caller, we'll just need to remember to properly define it everywhere.)

@annevk
Copy link
Member

annevk commented Apr 16, 2016

We should probably patch all of those. Would you be willing to file a sibling issue against whatwg/html?

@ArkadiuszMichalski
Copy link
Contributor Author

I will open but definitions for element should be more universal, this node has some internal state and now only shadow root has initial null value. Writing in other specs just "create a new xxx element" is too general, directly using create an element requires passing 5 or 6 values what is uncomfortable.

@annevk
Copy link
Member

annevk commented Apr 18, 2016

Yeah, @domenic was positing that there would not be many callers and therefore uncomfortable was fine, but I think he might have been mistaken to some extent, but we can refactor once we find out for sure.

@ArkadiuszMichalski
Copy link
Contributor Author

P&S also creates new elements, only one time missing node document for parseFromString step 4.. @annevk any plans in the near future to bring back P&S under the WHATWG?
And don't forget about innerText (also creates text and element nodes).

@annevk
Copy link
Member

annevk commented Apr 18, 2016

No concrete plans, though with it not being maintained it's somewhat rising in importance.

domenic added a commit that referenced this issue Apr 18, 2016
domenic added a commit that referenced this issue Apr 18, 2016
domenic added a commit that referenced this issue Apr 18, 2016
annevk pushed a commit that referenced this issue Apr 19, 2016
domenic added a commit that referenced this issue Apr 20, 2016
Takes care of part of #212.

(cherry picked from commit 7b42a54)

# Conflicts:
#	dom.bs
#	dom.html
tabatkins added a commit to tabatkins/dom that referenced this issue Apr 28, 2016
* Add more legacy event types for createEvent()

Approximately as requested at
https://bugzilla.mozilla.org/show_bug.cgi?id=1251198#c7. This is the
list of events supported in createEvent() by at least two of Firefox,
Chrome, and IE 11. The one exception is I omitted MutationEvent,
which all three support, because apparently spec-land has decided to
deny its existence in the hope that it will go away.

Bikeshed does not know about all of the added interface names,
hopefully that will sort itself out over time.

* Meta: improve pull request instructions for DOM

See whatwg/fetch#276 for context.

* Enable an event listener to be invoked just once

* Editorial: web compatibility typically remains relevant

Fixes whatwg#210.

* Shadow: define attachShadow() for custom elements

* Meta: make it easier to reference participate in a tree

PR: whatwg#216

* Define node document for new Text nodes

Fixes whatwg#224 and part of whatwg#212. Also fix part of whatwg#209 by stating these
algorithms can rethrow exceptions.

* Use a single concept for attribute changes

This setup is still a little sketchy I think, but not more so than the
insertion and removing steps.

* SVGEvent is only Gecko, Blink also has SVGEvents

As pointed out by zcorpan in whatwg#227.

* Set createDocument()'s content type based on namespace

Fixes whatwg#217.

PR: whatwg#218

* Make document.createEvent("touchevent") sometimes throw

Browsers typically disable touch events on non-touch devices, and there exists web content that detects this difference using document.createEvent().

Fixes whatwg#227.

* Shadow: define slotchange event

Shadow: define slotchange event

Fixes WICG/webcomponents#288.

This defines the slotchange event in response to remove/insert operations, changes to a slot’s name attribute, and changes to an element’s slot attribute.

This also introduces the assigned nodes concept for slots, and assigned slot concept for slotables.

Slotables now also have a name, rather than a “get name”.

The slotchange event dispatches just after mutation observers have their callbacks invoked. The slotchange event is not yet marked scoped as scoped events are not yet defined in the DOM Standard.

Note: although the original issue did not mention it, this also suppresses signaling when slots are removed from a tree. Not just when they are inserted.

* Editorial: update custom element cross-spec references

* Editorial: fix a few cross-linking missteps

* Editorial: make "is" and "prefix" optional in "create an element"

* Use "create an element" in createHTMLDocument

Takes care of part of whatwg#212.

* Editorial: align exception language with IDL

* Editorial: introduce more shadow-including terms for CSS

Fixes whatwg#225.

* Editorial: distributed -> flattened

* Meta: export more terms

Fixes whatwg#233.

* Editorial: add "shadow host" and "assigned" as terms

This makes a couple of non-null checks read better and enshrines a term
we had already been using.

* Editorial: flip non-null/otherwise conditions

PR: whatwg#234

* Shadow: <slot> is now defined in HTML

* Remove passive as event listener key

This changes makes passive no longer contribute to the uniqueness of
an event listener. It therefore also no longer needs to be supported
as part of removeEventListener().

Fixes WICG/EventListenerOptions#27.

PR: whatwg#236

* Meta: point out event's timeStamp is likely to change

See whatwg#23 for details.

* Add [CEReactions] annotations to mutating methods

Part of WICG/webcomponents#186, and furthering whatwg/html@27aa7bc.

Linking [CEREactions] will happen once speced/bikeshed#677 is fixed.

* Editorial: check stop propagation flag at start of invoke

* Editorial: deduplicate Veli Şenol

* Editorial: define defaults for EventListenerOptions

Although this is also done in prose, this nonetheless simplifies the
prose a bit and makes it clearer to those skimming the standard what is
going on (although skimming is not recommended).

Fixes whatwg#239.

* Meta: link to Japanese translation

See
triple-underscore/triple-underscore.github.io#1
for more details.
@annevk
Copy link
Member

annevk commented Aug 16, 2016

Closing this since it's addressed in DOM and HTML.

@annevk annevk closed this as completed Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants