Browse Source

Remove outdated non-implementations of §3.4

develop
Gerben 4 years ago
parent
commit
3bb89f1807
3 changed files with 3 additions and 73 deletions
  1. +0
    -3
      src/common.ts
  2. +3
    -44
      src/index.ts
  3. +0
    -26
      src/whatwg-html.ts

+ 0
- 3
src/common.ts View File

@@ -1,6 +1,3 @@
export type nonEmptyString = string;
export type integer = number;

export type locale = string; export type locale = string;


export function nextNode(node: Node): Node | null { export function nextNode(node: Node): Node | null {


+ 3
- 44
src/index.ts View File

@@ -8,8 +8,6 @@




import { import {
nonEmptyString,
integer,
locale, locale,
isElement, isElement,
nextNode, nextNode,
@@ -27,7 +25,6 @@ import {


import { import {
languageOf, languageOf,
origin,
serializesAsVoid, serializesAsVoid,
isBeingRendered, isBeingRendered,
} from './whatwg-html.js'; } from './whatwg-html.js';
@@ -36,6 +33,9 @@ import {
htmlNamespace, htmlNamespace,
} from './whatwg-infra.js'; } from './whatwg-infra.js';


type nonEmptyString = string;
type integer = number;



// § 3.3.1. Parsing the fragment directive // § 3.3.1. Parsing the fragment directive


@@ -201,47 +201,6 @@ export function isTextFragmentDirective(input: string): input is TextDirective {
} }




// § 3.4. Security and Privacy


// § 3.4.4 Restricting the Text Fragment

// https://wicg.github.io/scroll-to-text-fragment/#should-allow-a-text-fragment
// “To determine whether a navigation should allow a text fragment, given as input a boolean is user triggered, an origin incumbentNavigationOrigin, and Document document; follow these steps:”
export function shouldAllowTextFragment(isUserTriggered: boolean, incumbentNavigationOrigin: origin | null, document: Document): boolean {
// 1. “If incumbentNavigationOrigin is null, return true.”
// XXX This implies null is a potential value of the parameter (is this implicitly allowed in web specs?). (note that an opaque origin is serialised to null, but that is presumably not the situation meant here)
if (incumbentNavigationOrigin === null)
return true;

// 2. “If is user triggered is false, return false.”
if (isUserTriggered === false)
return false;

// 3. “If the document of the latest entry in document’s browsing context's session history is equal to document, return false.”
// 4. “If incumbentNavigationOrigin is equal to the origin of document return true.”
// 5. “If document’s browsing context is a top-level browsing context and its group’s browsing context set has length 1 return true.”
// NOT IMPLEMENTED. Implementing these steps would require reproducing a bunch of browser internals. Probably not worthwhile.

// 6. “Otherwise, return false.”
return false;
}

// https://wicg.github.io/scroll-to-text-fragment/#allowtextfragmentdirective
// “To set the allowTextFragmentDirective flag, follow these steps:”
// XXX Is this line supposed to be there? Looks like it may have left by accident while changing the approach.

// “Amend the page load processing model for HTML files to insert these steps after step 1:
// 2. “Let is user activated be true if the current navigation was initiated from a window that had a transient activation at the time the navigation was initiated.”
// 3. “Set document’s allowTextFragmentDirective flag to the result of running should allow a text fragment with is user activated, incumbentNavigationOrigin, and the document.”
// Amend the try to scroll to the fragment steps by replacing the steps of the task queued in step 2:
// 1. “If document has no parser, or its parser has stopped parsing, or the user agent has reason to believe the user is no longer interested in scrolling to the fragment, then clear document’s allowTextFragmentDirective flag and abort these steps.”
// 2. “Scroll to the fragment given in document’s URL. If this does not find an indicated part of the document, then try to scroll to the fragment for document.”
// 3. “Clear document’s allowTextFragmentDirective flag””

// NOT IMPLEMENTED. Implementing these amendments would require reproducing a bunch of browser internals. Not deemed worthwhile here.


// § 3.5. Navigating to a Text Fragment // § 3.5. Navigating to a Text Fragment


// https://wicg.github.io/scroll-to-text-fragment/#navigating-to-text-fragment // https://wicg.github.io/scroll-to-text-fragment/#navigating-to-text-fragment


+ 0
- 26
src/whatwg-html.ts View File

@@ -6,10 +6,8 @@




import { import {
integer,
locale, locale,
isElement, isElement,
nonEmptyString,
} from './common.js'; } from './common.js';


import { import {
@@ -98,30 +96,6 @@ export function getPragmaSetDefaultLanguage(): string | undefined {
} }




// § 7.5 Origin
// https://html.spec.whatwg.org/multipage/origin.html#concept-origin
// “An origin is one of the following:”
export type origin = opaqueOrigin | tupleOrigin

// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-opaque
// “An opaque origin”: “An internal value, with no serialization it can be recreated from (it is serialized as "null" per serialization of an origin), for which the only meaningful operation is testing for equality.”
export type opaqueOrigin = symbol; // I guess?

// https://html.spec.whatwg.org/multipage/origin.html#concept-origin-tuple
// “A tuple origin”: “A tuple consists of:
// • A scheme (a scheme).
// • A host (a host).
// • A port (a port).
// • A domain (null or a domain). Null unless stated otherwise.”
export type tupleOrigin = [
// (using primitive types here; specifying these further is beyond scope)
string,
string | integer | integer[], // integers for IP addresses
integer | null,
nonEmptyString | null,
];


// § 12.1.2 Elements // § 12.1.2 Elements
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
export const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']; export const voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];


Loading…
Cancel
Save